Skip to content

Instantly share code, notes, and snippets.

@savvisingh
Last active September 23, 2019 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save savvisingh/c505850838765cf0f4cd4ba7561ec1ad to your computer and use it in GitHub Desktop.
Save savvisingh/c505850838765cf0f4cd4ba7561ec1ad to your computer and use it in GitHub Desktop.
// Create a listener to track downloading state updates.
val listener = InstallStateUpdatedListener { state ->
// Update progress indicator, request user to approve app reload
if (state.installStatus() == InstallStatus.DOWNLOADING) {
// show the progress to the User
updateStatetoDownloading()
}else if (state.installStatus() == InstallStatus.DOWNLOADED) {
// After the update is downloaded, show a notification
// and request user confirmation to restart the app.
popupSnackbarForCompleteUpdate()
}
}
// At some point before starting an update, register a listener for updates.
appUpdateManager.registerListener(listener)
// At some point when status updates are no longer needed,unregister the listener.
appUpdateManager.unregisterListener(listener)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment