如何修复 SecurityException:权限拒绝:打开未从 uid 导出的提供程序

问题描述

我想打开另一个带有导入窗口的应用程序并将文件发送给它进行处理。

final Intent sendIntent = new Intent(Intent.ACTION_MAIN);
sendIntent.setComponent(new ComponentName("com.example.editor","com.example.editor.ActivityImportFile"));

Uri uri = FileProvider.getUriForFile(ma,BuildConfig.APPLICATION_ID + ".provider",file);
ArrayList<Uri> uris = new ArrayList<>();
uris.add(uri);
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);
ma.startActivity(sendIntent);

在第二个应用程序中,我得到了 Uri 并且我想查看它的属性,但在

Cursor cursor = context.getContentResolver().query(uri,null,null);

如果您通过应用程序选择窗口发送 Uri,那么一切正常,但是如果您通过指定确切的包和活动来打开程序,则错误是:

java.lang.SecurityException: Permission Denial: opening provider com.example.viewer.zecondary.GenericFileProvider from ProcessRecord{1b99fc80 16269:com.example.editor/u0a207} (pid=16269,uid=10207) that is not exported from uid 10204

我试过这个 android.exported=true 但这是被禁止

如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)