Skip to content

Instantly share code, notes, and snippets.

@varundwarkani
Created March 11, 2020 17:27
Show Gist options
  • Save varundwarkani/4984c2b9f5ecd45cbec9ae88994c3e78 to your computer and use it in GitHub Desktop.
Save varundwarkani/4984c2b9f5ecd45cbec9ae88994c3e78 to your computer and use it in GitHub Desktop.
InAppUpdateListener
private void setInAppUpdateSuccessListener(final boolean compulsory) {
if (appUpdateManager == null) {
appUpdateManager = AppUpdateManagerFactory.create(getApplicationContext());
}
appUpdateManager.getAppUpdateInfo().addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() {
@Override
public void onSuccess(AppUpdateInfo appUpdateInfo) {
if (appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
try {
//call startInAppUpdate() from here as the user might have started an update before but did not download it completely.
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
} else if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
popupSnackbarForCompleteUpdate();
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment