我已按照下面提到的步骤集成应用内更新。
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
)
第一步,我们检查是否有更新,更新是即时的还是灵活的。
我们在哪里指定我们将在第一步中获得的更新类型?
我的意思是说 ki 我必须在哪里指定我的当前更新是否是立即强制更新?
最佳答案
我已将其用于强制更新或稍后更新以进行应用程序更新,这对我很有用。
我习惯使用 firebase 更新应用
https://readyandroid.wordpress.com/force-app-update-androidfirebase/
关于android - 在 Android 中实现应用程序更新功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58335161/