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
appUpdateManager | |
.appUpdateInfo | |
.addOnSuccessListener { appUpdateInfo -> | |
... | |
// If the update is downloaded but not installed, | |
// notify the user to complete the update. | |
if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) { | |
popupSnackbarForCompleteUpdate() | |
} |
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
// 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.DOWNLOADED) { | |
// After the update is downloaded, show a notification | |
// and request user confirmation to restart the app. | |
popupSnackbarForCompleteUpdate() | |
} | |
} |
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
appUpdateManager.startUpdateFlowForResult( | |
// Pass the intent that is returned by getAppUpdateInfo() | |
appUpdateInfo, | |
AppUpdateType.FLEXIBLE, activity, | |
// Include a request code to later monitor this update request. | |
MY_REQUEST_CODE | |
) |
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
fun onActivityResult(requestCode:Int, resultCode:Int, data:Intent) { | |
if (myRequestCode === MY_REQUEST_CODE){ | |
if (myRequestCode !== RESULT_OK){ | |
log("Update flow failed! Result code: " + resultCode) | |
// If the update is cancelled or fails, | |
// you can request to start the update again. | |
} | |
} | |
} |
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
appUpdateManager.startUpdateFlowForResult( | |
// Pass the intent that is returned by 'getAppUpdateInfo()'. | |
appUpdateInfo, | |
// Or 'AppUpdateType.FLEXIBLE' for flexible updates. | |
AppUpdateType.IMMEDIATE, | |
// The current activity making the update request. | |
this, |
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
// 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 | |