SAF: App Inventor implementation of Storage Access Framework

So as you said here, now you are able to open pdf files with the help of external applications.

1 Like

@vknow360 not exactly, what I was telling Taifun is that when I select the pdf file with SAF and get the Uri, I put it in the DataUri of ActivityStarter and it did not open the file. Then he suggested me to try to convert it to a normal path like file:///storage/emulated/0/... with its extension or with Filetools. And getting the path didn't work with TaifunFile and Filetools did (only the Uri to path), but even putting this path in the activitystarter DataUri still doesn't open pdfs (with android 11, this same thing on my tablet with android 8 opens pdfs without problems).

1 Like

He has a similar problem:

But, unfortunately, I haven't checked anything till yet.

1 Like

Yes it must be the same. I'm in no hurry, if one day it's available great!
Thank you very much anyway!

1 Like

@vknow360
Hello, Sunny
When you can, of course.
Thanks for your help.

Hi Toni, I found a solution for my application. Hope this can help you.
All the best.

1 Like

This only works because the PDF file is created (downloaded) by the app itself.
If the file has already been manually saved in this folder (/Download) by yourself or by another app, this will not work.

Correct @Anke
I am also searching solution for opening a pdf file already stored in Documents folder.
Can the possible solution be -
to copy this file to ASD by using SAF extention by @vknow360 and then try opening it from ASD.?

Thank you @Clipper for the solution you share. I have tried it and it works!
but in my case I need to open pdfs that are in the internal storage of the mobile.

I understand, it is a different problem. Could it be fixed by having Activity Starter open a file explorer folder?

Hi Anke, you are right, it is a different problem.

For that solution is to grant temporary uri access to the external app which seems to be possible with ActivityStarter.

What do you mean by "internal storage". An app can only access its own (private) internal storage (privateDir).

/data/user/0/<packageName>/files/

For example:
/storage/emulated/0/Documents
or any directory from:
/storage/emulated/0/....

This is a folder in the external storage (and also one of the Shared folders).
To open / access non-media files, that are not created by the app itself, from the external storage (or even from a Shared folder) you need SAF.

See here:

that's what I tried as I put here in the photo. Unless you mean something different or another way....
saf

Button2 click has nothing to do with SAF.
You only got the filePath with SAF and the FileTools extension.

But how to open the document with SAF?
As far as I understand, SAF itself does not open files.

Trying things I have discovered that with the Librera app I can open PDFs. It is the only one that has worked for me of the ones I have tried. I don't know why, but maybe it's a clue to what happens with Android 11.
I usually use Readera from my app, which is the one that works best for me, but if Librera works on my phone it's fine!

@Toni are you using that app together with the blocks you recently posted?
it might be, that the Librera app still uses SDK29?

if there is a solution to copy the pdf file from the shared storage to the ASD, then a pdf extension could be used to open and render the pdf file from there...

did anyone find a solution to copy a non media file from shared storage to the ASD?

this is what I tried:
Unbenannt
which results in error message
Unbenannt2
which means, the SAF extension is not able to copy something into the ASD without permission?

here I tried to get permission, which failed...

Taifun