Skip to content

Instantly share code, notes, and snippets.

@DanishAmjad12
Last active April 5, 2020 16:40
Show Gist options
  • Save DanishAmjad12/500f2e709c69ec5d57c69b8718bcb9d0 to your computer and use it in GitHub Desktop.
Save DanishAmjad12/500f2e709c69ec5d57c69b8718bcb9d0 to your computer and use it in GitHub Desktop.
private fun checkUpdate() {
// 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.
Log.d(TAG, "Checking for updates")
appUpdateInfoTask?.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
// Request the update.
Log.d(TAG, "Update available")
} else {
Log.d(TAG, "No Update available")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment