我已按照下面提到的步骤集成应用内更新。
1) 检查更新可用性
// 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
}
}
2)如果有更新则触发更新流程
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,
// Include a request code to later monitor this update request.
MY_REQUEST_CODE
)
在第一步中,我们检查是否有更新以及更新是立即的还是灵活的。
我们在哪里指定我们将在第一步中获得的更新类型?
我的意思是说我必须在哪里指定我当前的更新是否是强制更新的即时更新?