The problem I have on Android 11 is as follow: My app is downloading a file (image for example) form internet. The app first lets the user select the folder to store the file using Intent.ACTION_OPEN_DOCUMENT_TREE. This step gives the app SAF access to the folder to create the file and download it. Next I would like to let the user open the image using another intent:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(fileUri);//uri as returned form SAF when creating the file.
(intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); doesn't help) But if the other app tries to open the file I got different errors:
No permission grants found for com.google.android.apps.photos or Error when parsing file name from intent: Permission Denial: opening provider com.android.externalstorage.ExternalStorageProvider from ProcessRecord{731d51b 4366:com.rhmsoft.edit/u0a277} (pid=4366, uid=10277) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
It looks like a catch 22? I am only using uri (I do not have any file, nor I needed it) but I have no way to share a file I have created using SAF?
Thank you very much!