0

I have updated my app using the google play core library .but even after app downloaded the update,when the app comes to specific activity(where updating described)updation starts again.

I have followed all the rules downloaded an update first of all starting auto update Using it in a release apk

fun initUpdate() {
    val appUpdateManager = AppUpdateManagerFactory.create(this)
    val appUpdateInfoTask = appUpdateManager.appUpdateInfo
    appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
    if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
    ) {
    appUpdateManager.startUpdateFlowForResult(appUpdateInfo, AppUpdateType. IMMEDIATE, this, MY_REQUEST_CODE
    )}}}

 override fun initComponents() {
        initUpdate()
        //rest of the coe//
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

0

this line

 if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)

checks only if it is available -> then it updates. Maybe adding some version flag like a version number, that you keep track off would help

Once you have that set up you can add an extra bit of logic to your code

if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) && versionCode != curversion)
SomethingCool
  • 303
  • 2
  • 20
  • even after the download is complete ,app version shows previous one itself.I think download doesn't completes correctly,is there anything we can do in this case –  Sep 04 '19 at 05:20
  • well clearly you are not incrementing the version number. Release new app - version 1.0.1 eg. Have a local version on your device which is 1.0.0. Once you alter the if statement it should update accordingly. You need to have two apps with this logic and version numbers assigned to them. I would even store it in the db somewhere the curent version number so once the app starts it queries what is the current version if the app is out of date (the version number is lower than the current version number) it will run the update. – SomethingCool Sep 04 '19 at 10:16