1

I am implementing android's In-App update. The problem I am facing is when the user kills application during app update and reopens it.

Need To Do:

On app reopen, I need to show install state according to the type of update, but there seems no way to differentiate the type of update going on.

If install state is InstallStatus.DOWNLOADED and update type is Flexible, I need to show a Snackbar to the user stating that update has been downloaded with install action. And if update type is Immediate and update is in progress, I need to continue with google Immediate update screen.

What is happening

I have added this code in my activity's onStart callback. When update type Flexible is in progress(not downloaded), it is going in else case every time, getting update availability UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS.

public void checkIfUpdateInProgress() {

        mAppUpdateManager.getAppUpdateInfo().addOnSuccessListener(appUpdateInfo -> {

mAppUpdateInfo = appUpdateInfo;
            if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
                showUpdateDownloadedSnackbar();
            } else if (appUpdateInfo.updateAvailability()
                    == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
                requestImmediateUpdate();
            }
        });

    }



    public void requestImmediateUpdate() {

        try {
            mAppUpdateManager.startUpdateFlowForResult(
                    // Pass the intent that is returned by 'getAppUpdateInfo()'.
                    mAppUpdateInfo,
                    // Or 'AppUpdateType.FLEXIBLE' for flexible updates.
                    AppUpdateType.IMMEDIATE,
                    // The current activity making the update request.
                    MyJsActivity.this,
                    // Include a request code to later monitor this update request.
                    REQUEST_CODE_APP_UPDATE_IMMEDIATE);
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
        }

    }

VishnuPrajapati
  • 119
  • 1
  • 6

0 Answers0