【发布时间】:2020-04-06 14:07:15
【问题描述】:
我正在尝试通过我的应用程序显示更新,但出现以下错误
com.google.android.play.core.install.InstallException:安装错误:-3
这是检查和更新App的代码
public void checkAppUpdate(){
// Creates instance of the manager.
// Returns an intent object that you use to check for an update.
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
// Checks whether the platform allows the specified type of update,
// and checks the update priority.
appUpdateInfoTask.addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() {
@Override
public void onSuccess(AppUpdateInfo appUpdateInfo) {
Log.i("UpdateError123",appUpdateInfo.updateAvailability()+"");
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
// Request an immediate update.
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.
MainActivity.this,
// Include a request code to later monitor this update request.
1021);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
}
});
appUpdateInfoTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
e.printStackTrace();
Log.i("UpdateError",e.toString()+"");
}
});
}
【问题讨论】:
-
我已经成功地在我的应用中实现了应用内更新并发表了一篇文章。只需从那里复制粘贴,一切都会奏效。这是链接:medium.com/@sa159871/…
标签: android in-app-update app-update