【发布时间】:2019-11-06 04:36:54
【问题描述】:
Playstore 控制台中是否有任何选项可用于配置此值?
这是官方文档。代码:
// 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.
}
});
我们如何知道:
appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
上面的类型在哪里配置?官方文档上没有相关描述。
在 AppUpdateInfo.class 中:
public final boolean isUpdateTypeAllowed(int var1) {
if (var1 == 0) {
return this.f != null;
} else if (var1 == 1) {
return this.e != null;
} else {
return false;
}
}
其中f 和e 是PendingIntent,方法根据它们的值返回true 或false。
【问题讨论】:
-
恐怕没有办法通过 Play 控制台远程配置它。我们必须在我们的服务器中使用网络 API 来检查这一点。
标签: android in-app-update google-play-core