AppUpdateManager.startUpdateFlowForResult causing IntentSender$SendIntentException

Viewed 607

In-app update is available multiple times in my app. User can cancel the update first time while opening the app and choose to trigger in-app Update from another fragment manually.

As per Google documentation, I have created new instances each time to trigger the update but it is only working for the first. Next time, it's causing AppUpdateManager.startUpdateFlowForResult causing IntentSender$SendIntentException

private void init() {
        appUpdateManager = AppUpdateManagerFactory.create(mContext);
        appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();

    }

 public void checkAppUpdate() {
            appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
                .....................................
                .....................................
                startAppUpdate(appUpdateInfo);
   
        }

private void startAppUpdate(AppUpdateInfo appUpdateInfo) {
        Log.d(TAG, "startAppUpdate: starting app update");
        appUpdateManager.startUpdateFlowForResult(
                appUpdateInfo,
                appUpdateType,
                mActivityReference,
                mRequestCode);
    }
1 Answers

As mentioned in the Documentation, there are different flow to trigger Google App Update API from different components in app. We need to trigger correct flow according to our requirements.

startUpdateFlow(AppUpdateInfo appUpdateInfo, Activity activity, AppUpdateOptions options)
Starts the desired update flow asynchronously.

startUpdateFlowForResult(AppUpdateInfo appUpdateInfo, int appUpdateType, IntentSenderForResultStarter starter, int requestCode)
Starts the desired update flow.

startUpdateFlowForResult(AppUpdateInfo appUpdateInfo, Activity activity, AppUpdateOptions options, int requestCode)
Starts the desired update flow.

startUpdateFlowForResult(AppUpdateInfo appUpdateInfo, int appUpdateType, Activity activity, int requestCode)
Starts the desired update flow.

startUpdateFlowForResult(AppUpdateInfo appUpdateInfo, IntentSenderForResultStarter starter, AppUpdateOptions options, int requestCod
Related