Created
March 11, 2020 17:27
-
-
Save varundwarkani/4984c2b9f5ecd45cbec9ae88994c3e78 to your computer and use it in GitHub Desktop.
InAppUpdateListener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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