In-App Update Dialog Still showing after updating the app

593 Views Asked by At

I'm using the in app update api for getting new update for my app but I'm still getting the update App dialog after update the App from Play store while testing the release signed apk . Please help me why I'm getting the update app option when it's already updated app.

1

There are 1 best solutions below

0
Adriana Mendez On

You should have an implementation in order to manage the listener and unregister it when status is installed.

Similar to this

private lateinit var appUpdateManager: AppUpdateManager
private lateinit var updateListener: InstallStateUpdatedListener

private fun setUpdateAction(context: Activity) {
    updateListener = InstallStateUpdatedListener {
        when (it.installStatus()) {
            InstallStatus.FAILED,
            InstallStatus.UNKNOWN,
            InstallStatus.CANCELED -> {
                unregisterListener(updateListener)
                setErrorUpdateListener()
            }
            InstallStatus.DOWNLOADED -> {
                updateDownloaded()
            }
            InstallStatus.INSTALLED -> {
                unregisterListener(updateListener)
            }
            InstallStatus.DOWNLOADING,
            InstallStatus.INSTALLING,
            InstallStatus.PENDING -> {
                //Other App update states
            }
            else -> {
                //Undefined error
                unregisterListener(updateListener)
                setErrorUpdateListener()
            }
        }
    }
    appUpdateManager.registerListener(updateListener)
    startInAppUpdate(context, AppUpdateType.FLEXIBLE)
}

private fun unregisterListener(listener: InstallStateUpdatedListener) {
    appUpdateManager.unregisterListener(listener)
}