gpt4 book ai didi

android - 来自 ProcessRecord 的 java.lang.SecurityException : Permission Denial: opening provider android. support.v4.content.FileProvider

转载 作者:行者123 更新时间:2023-11-29 00:03:34 30 4
gpt4 key购买 nike

java.lang.SecurityException: Permission Denial: opening provider android.support.v4.content.FileProvider from ProcessRecord

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="cn.cloudworkshop.miaoding.fileprovider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"
tools:replace="android:resource"/>
</provider>

java代码:

 @Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
Intent install = new Intent(Intent.ACTION_VIEW);
Uri contentUri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
contentUri = FileProvider.getUriForFile(context, "cn.cloudworkshop.miaoding.fileprovider", file);
} else {
contentUri = Uri.fromFile(file);

}
install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
install.setDataAndType(contentUri, "application/vnd.android.package-archive");
context.startActivity(install);
}
}

install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

这段代码导致了这个问题,但是我删除了这段代码,这个应用程序安装后会崩溃。

最佳答案

宝贝~你不能这样试:

installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK)

我猜需要放在一起,权限允许 activity_new_task!

关于android - 来自 ProcessRecord 的 java.lang.SecurityException : Permission Denial: opening provider android. support.v4.content.FileProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44712545/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com