5
应用内更新提供InstallException(ERROR_API_NOT_AVAILABLE)
使用以下代码段实现了应用内更新功能: private void showInAppUpdateDialog(boolean isMandatoryUpdate) { Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo(); appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> { if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE || appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) { int appUpdateType = isMandatoryUpdate ? IMMEDIATE : AppUpdateType.FLEXIBLE; int requestCode = isMandatoryUpdate ? REQUEST_APP_UPDATE_IMMEDIATE : REQUEST_APP_UPDATE_FLEXIBLE; if (appUpdateInfo.isUpdateTypeAllowed(appUpdateType)) { // start the app update try { appUpdateManager.startUpdateFlowForResult(appUpdateInfo, appUpdateType, …