2

I want to open another application with an import window and send a file to it for processing.

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);

in the second application I get Uri and I want to see its properties but I get an error on the

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

If you send Uri through the application selection window, then everything works, but if you open the program by specifying the exact package and Activity, the error is:

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

I tried this android.exported=true but it is forbidden

How to fix it?

quass1234
  • 51
  • 4
  • Does this answer your question? [Android - file provider - permission denial](https://stackoverflow.com/questions/24467696/android-file-provider-permission-denial) – Sam Jul 26 '22 at 23:41

1 Answers1

0

This worked for me (Kotlin): context.grantUriPermission("com.example.editor", uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION)

Sam
  • 261
  • 2
  • 11