Skip to content

Instantly share code, notes, and snippets.

@varundwarkani
Created March 11, 2020 17:24
Show Gist options
  • Save varundwarkani/f731a4b350904a5a21938b4ebb588b5b to your computer and use it in GitHub Desktop.
Save varundwarkani/f731a4b350904a5a21938b4ebb588b5b to your computer and use it in GitHub Desktop.
InAppUpdateStartInAppUpdate
//Boolean Compulsory is used to decide whether to start immediate update or flexible update.
private void startInAppUpdate(AppUpdateInfo appUpdateInfo, boolean compulsory) {
try {
if (compulsory) {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
IMMEDIATE,
this,
UPDATE_REQUEST_CODE);
} else {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.FLEXIBLE,
this,
Utils.showSnackbar(findViewById(android.R.id.content), "An update has been started. You will be notified when it is complete.", 2);
}
setInAppUpdateSuccessListener(compulsory);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment