sdex / ActivityManager

Launch any application activity
Apache License 2.0
592 stars 33 forks source link

[Feature request] Pass URI resources with --grant-read/write-uri-permission to launched application #90

Open AlainKnaff opened 2 months ago

AlainKnaff commented 2 months ago

I'm trying to use activity manager to make a shortcut to open up a text file in an editor.

I can tell the editor which file to attempt to open by including it into the data part of the intent, such as content://com.termux.documents/document/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome%2FAchats.txt or content://com.android.externalstorage.documents/primary%3Aessai.txt

However, this fails because the editor has no permission.

If on the other hand, I tick the FLAG_GRANT_READ_URI_PERMISSION, i get an error because ActivityManager has no permission :-)

Suggestion: include a UI where ActivityManager can request a persistable-uri-permission from the user (this would pop up a file picker, where user chooses the file to make accessible), and use that permission to grant to the target. Another advantage of this would be that this removes the hassle of needing to figure out what the URI of the file actually is (see the 2 rather unreadable examples in the second paragraph).

The Shortcut Maker app from Playstore handles it this way, but unfortunately has other bugs which makes it not usable (drops other flags such as FLAG_ACTIVITY_MULTIPLE_TASK and FLAG_ACTIVITY_NEW_DOCUMENT)

Thanks,

Alain