我应该在哪里设置应用程序更新类型?我在游戏机上找不到它。
此代码从哪里知道可用的更新类型?
// Creates instance of the manager.
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(context);
// Returns an intent object that you use to check for an update.
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
// Checks that the platform will allow the specified type of update.
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
// For a flexible update, use AppUpdateType.FLEXIBLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
// Request the update.
}
});
答案 0 :(得分:0)
那应该是您应用程序的启动活动
1)检查更新可用性
2)在确认您能够更新应用后,您可以使用
请求更新AppUpdateManager.startUpdateFlowForResult()
喜欢
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)
3) 那么您可以使用onActivityResult()回调来处理更新失败或取消的情况,
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
if (requestCode == MY_REQUEST_CODE) {
if (resultCode != RESULT_OK) {
log("Update flow failed! Result code: $resultCode")
// If the update is cancelled or fails,
// you can request to start the update again.
}
}
}
有关更多详细信息,请参见Support in-app updates
答案 1 :(得分:0)
我们需要调用这个:PUT API
https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/edits/{editId}/tracks/{track}
在正文中传递数据:
{
"releases": [{
"versionCodes": ["12"],
"inAppUpdatePriority": 5,
"status": "completed"
}]
}
为了确定优先级,Google Play 使用 0 到 5 之间的整数值,其中 0 是默认值,5 是最高优先级。 例如,考虑以下设置更新优先级的策略:
有关完整信息,您可以参考以下链接:
https://developers.google.com/android-publisher/api-ref/rest/v3/edits.tracks/update