Sujet : Re: viewing local htm files on Android device
De : usenet (at) *nospam* arnowelzel.de (Arno Welzel)
Groupes : comp.mobile.androidDate : 26. Jul 2024, 16:50:06
Autres entêtes
Message-ID : <lghutdFpls7U3@mid.individual.net>
References : 1
Malone, 2024-07-23 07:31:
I've created a simple (just text, no script) .htm file on a Windows
computer ("testhtm.htm") and transferred it to my Android tablet.
In My Files - Downloads it then appears as "testhtm.htm". Tapping it and
it opens with Chrome (my default browser) as
"content:media/external/file/1000000383".
Long tap and select "Add to Home Screen" and an icon appears on the home
screen titled "testhtm". And when tapping this it opens in Chrome.
If I now restart (reboot) the tablet and try to open the file by tapping
its icon on the home page it doesn't open and I receive the message:
"Chrome does not have access to the requested resource."
If I then go to My Files - Downloads I find I can open it from there.
And if I then go back to the home page it will now open from there as well.
Why is this?
I think access to "content:media/external/file/1000000383" is only
granted using a temporary access token which gets lost when rebooting
the device.
I had this issue with my own app when it asked for permission to access
files using the Storage Access Framework. Technically it needs to add
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION to the request, so the
access token is persistent and survices reboots.
Also see here:
<
https://developer.android.com/reference/android/content/Intent#FLAG_GRANT_PERSISTABLE_URI_PERMISSION>
Quote:
"When combined with FLAG_GRANT_READ_URI_PERMISSION and/or
FLAG_GRANT_WRITE_URI_PERMISSION, the URI permission grant can be
persisted across device reboots until explicitly revoked with
Context#revokeUriPermission(Uri, int)."
Without this flag, a read permission will be lost after a reboot.
So the only real solution to this would be to use a browser which
creates a permanent access token when adding the shortcut to the
launcher. Maybe it helps when you open it in Chrome first and use Chrome
to add the shortcut to the home screen and not the file manager.
-- Arno Welzelhttps://arnowelzel.de