Skip to content

Instantly share code, notes, and snippets.

@savvisingh
Last active September 23, 2019 10:30
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/e32a241ee73f88f1b31691103aed6b92 to your computer and use it in GitHub Desktop.
Save savvisingh/e32a241ee73f88f1b31691103aed6b92 to your computer and use it in GitHub Desktop.
// Creates instance of the manager.
val appUpdateManager = AppUpdateManagerFactory.create(context)
// Returns an intent object that you use to check for an update.
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
// Checks that the platform will allow the specified type of update.
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
// For a immediate update, use AppUpdateType.IMMEDIATE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)
) {
// notify user that there is an available update
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment