Skip to content Skip to sidebar Skip to footer

Where To Put In-app Update Implementation In Android

I am trying to implement in app updates in my app, but there is a disconnect between the documentation/tutorials that I have looked at and the actual final implementation. I follow

Solution 1:

THIS ANSWER IS A HACK!

I have had quite a bit of trouble with in app updates. the issue being that this librery was made for users that stay in the same activity where startUpdateFlowForResult is called from and then whenever the user does something unexpected like checking whatsapp or going to the next activity everything breaks down and the update doesnt get completed. and you can try to fix it with endless boilerplate but since calling a snackbar that is activity agnostic is super complex that will cost you at least some gray hairs and leave you with delicate code that probably still is somewhat buggy.

THE ALTERNATIVE

I finally gave upand decided to redirect my users directly to GooglePlayStore:

if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE ) { //maybe you could add some additional checks like priority level heremakeUpdateDialog(mContext).show();
}

I use the In-app Updates library exclusively to check for availability and then I show a dialog with the following code in the action button:

try {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(ownGooglePlayLink)));
} catch (android.content.ActivityNotFoundException anfe) {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(ownWebLink)));
}

publicstaticfinalString ownGooglePlayLink="market://details?id=com.my.package.name";
publicstaticfinalString ownWebLink="https://play.google.com/store/apps/details?id=com.my.package.name";

This is admitedly very hacky but its not as bad as it seems. I find that the user experience remmains good and the user can either skip your update or return to the app after initializing the update.

Solution 2:

are you looking for this:

call to prompt for FlexibleUpdate, this will pop up the google prompt and the user can tap "Install" from there. It seems to handle the download/install all in one and i dont have to do the "reload" snackbar step the docs were talking about.

  appUpdateManager.startUpdateFlowForResult(appUpdateInfo, AppUpdateType.FLEXIBLE, activity, APP_UPDATE_REQUEST_CODE)

Post a Comment for "Where To Put In-app Update Implementation In Android"