【发布时间】:2021-08-30 11:30:37
【问题描述】:
我在我的 android 应用程序中实现了应用程序内更新功能,但在我转到 Playstore 应用程序并查看更新按钮之前它无法正常工作。 请建议我一些解决方案。 谢谢
public void ImmidateUpdate()
{
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(getActivity());
// 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)
{
if(appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE))
{
try {
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.
getActivity(),
// Include a request code to later monitor this update request.
1210);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
}
});
}
【问题讨论】:
标签: android in-app-update