我正在尝试在Nougat中更新我的应用程序,但我无法,我收到以下错误
File o = new File(String.valueOf(uri));
Uri myURI= FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", o);
Intent promptInstall = new Intent(Intent.ACTION_INSTALL_PACKAGE);
promptInstall.setDataAndType(myURI, "application/vnd.android.package-archive");
promptInstall.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
promptInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(promptInstall);
Caused by: java.lang.SecurityException: Permission Denial: opening provider
android.support.v4.content.FileProvider from ProcessRecord{9dfaa8c
1646:com.google.android.packageinstaller/u0a17} (pid=1646, uid=10017) that is
not exported from uid 10173
请帮我解决此问题
答案 0 :(得分:0)
最后我找到了解决方案
long referenceId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
if(downloadReference == referenceId) {
Timber.d("Downloading of the new app version complete");
//start the installation of the latest version
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType(dm.getUriForDownloadedFile(downloadReference),
"application/vnd.android.package-archive")
installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(installIntent);