有意在android中安装更新版本的应用程序
我有一个android应用程序,在启动时检查是否有新版本的应用程序可用。如果有更新版本,应用程序将下载.apk文件并将其存储在SD卡中。现在我想让launcher安装这个新版本。我该怎么办?试试这个:有意在android中安装更新版本的应用程序,android,Android,我有一个android应用程序,在启动时检查是否有新版本的应用程序可用。如果有更新版本,应用程序将下载.apk文件并将其存储在SD卡中。现在我想让launcher安装这个新版本。我该怎么办?试试这个: Intent installIntent= new Intent(Intent.ACTION_VIEW) installIntent.setData(Uri.parse("file:///path/to/your.apk")) installIntent.setType("
Intent installIntent= new Intent(Intent.ACTION_VIEW)
installIntent.setData(Uri.parse("file:///path/to/your.apk"))
installIntent.setType("application/vnd.android.package-archive");
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(installIntent);
它将提示安装程序视图。如果您的应用程序未使用与PackageManager相同的密钥进行签名,则无法进行直接静默安装。我遇到了一个异常:
android.content.ActivityNotFoundException:未找到可处理Intent的活动{act=android.Intent.action.VIEW typ=application/vnd.android.package-archive}
我添加了installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
一切正常!我对android 9 cordova中的webintent有一个问题(pie)你有什么解决方案吗?因为在android 6中,我可以轻松更新我的应用程序,但在android 9中,它说无法通过android Intent打开url。这只是一个猜测,但在6到9之间,关于文件访问有一些变化-可能你的apk存储在受限文件夹中。