• viewing local htm files on Android device

    From Malone@mslone@nospam.uk to comp.mobile.android on Tue Jul 23 17:31:24 2024
    From Newsgroup: comp.mobile.android


    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 have links on my home page to .htm pages located on servers on the
    internet which always open with no problems. But .htm files located on
    my tablet seem to become inaccessible from the home page after a reboot
    until opened from within My Files - Downloads.

    Can someone with a better understanding of the Android OS than me
    explain what's going on?





    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Dave Royal@dave@dave123royal.com to comp.mobile.android on Wed Jul 24 21:40:00 2024
    From Newsgroup: comp.mobile.android

    Malone <mslone@nospam.uk> Wrote in message:


    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 have links on my home page to .htm pages located on servers on the internet which always open with no problems. But .htm files located on
    my tablet seem to become inaccessible from the home page after a reboot until opened from within My Files - Downloads.

    Can someone with a better understanding of the Android OS than me
    explain what's going on?

    In the absence of an authoritative answer, and based on some
    googling (I am not a developer of Android apps), I'll offer a
    guess.

    I suspect that for the content URI in the shortcut (which is a
    pointer to a local resource, and AFAICS not the same as a file://
    URI) can only be accessed if Chrome has access to a Content
    Provider and for some reason (maybe a bug) there isn't one after
    a reboot. Perhaps accessing the content using My Files causes a
    Content Provider to be established, which can the be used by
    Chrome to access the content URI passed as a result of tapping
    the shortcut.

    <https://developer.android.com/guide/topics/providers/content-provider-basics> --
    Remove numerics from my email address.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Andy Burns@usenet@andyburns.uk to comp.mobile.android on Wed Jul 24 21:58:13 2024
    From Newsgroup: comp.mobile.android

    Dave Royal wrote:

    In the absence of an authoritative answer, and based on some
    googling (I am not a developer of Android apps), I'll offer a
    guess.

    I suspect that for the content URI in the shortcut (which is a
    pointer to a local resource, and AFAICS not the same as afile://
    URI)

    In a similar case, where we load a lot of documents (mixed .pdf and
    .html) onto an android tablet for use in a vehicle, we ended up
    installing a local web server on the tablet (and even paying the
    developer for a few tweaks to it).

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Malone@mslone@nospam.uk to comp.mobile.android on Fri Jul 26 07:28:13 2024
    From Newsgroup: comp.mobile.android

    On Thu-25-Jul-2024 8:40 am, Dave Royal wrote:
    Malone <mslone@nospam.uk> Wrote in message:


    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 have links on my home page to .htm pages located on servers on the
    internet which always open with no problems. But .htm files located on
    my tablet seem to become inaccessible from the home page after a reboot
    until opened from within My Files - Downloads.

    Can someone with a better understanding of the Android OS than me
    explain what's going on?

    In the absence of an authoritative answer, and based on some
    googling (I am not a developer of Android apps), I'll offer a
    guess.

    I suspect that for the content URI in the shortcut (which is a
    pointer to a local resource, and AFAICS not the same as a file://
    URI) can only be accessed if Chrome has access to a Content
    Provider and for some reason (maybe a bug) there isn't one after
    a reboot. Perhaps accessing the content using My Files causes a
    Content Provider to be established, which can the be used by
    Chrome to access the content URI passed as a result of tapping
    the shortcut.

    <https://developer.android.com/guide/topics/providers/content-provider-basics>

    Thanks for that Dave. It sounds plausible to me but it seems I'm still
    going to have to go to My Files to reactive the shortcut after a reboot
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Malone@mslone@nospam.uk to comp.mobile.android on Fri Jul 26 07:31:08 2024
    From Newsgroup: comp.mobile.android

    On Thu-25-Jul-2024 8:58 am, Andy Burns wrote:
    Dave Royal wrote:

    In the absence of an authoritative answer, and based on some
      googling (I am not a developer of Android apps), I'll offer a
      guess.

    I suspect that for the content URI in the shortcut (which is a
      pointer to a local resource, and AFAICS not the same as afile://
      URI)

    In a similar case, where we load a lot of documents (mixed .pdf and
    .html) onto an android tablet for use in a vehicle, we ended up
    installing a local web server on the tablet (and even paying the
    developer for a few tweaks to it).


    Thanks for that Andy. That sounds a great idea. Although I've installed
    a web server on my Window machine, doing a bit of googling suggests that
    doing something similar on an Android tablet is going to be slightly
    beyond my technical competence..
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Carlos E. R.@robin_listas@es.invalid to comp.mobile.android on Thu Jul 25 21:56:22 2024
    From Newsgroup: comp.mobile.android

    On 2024-07-23 07:31, Malone wrote:

    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 seem to recall old bug aka feature that file:/// would not work in
    Android. Re firefox, probably.
    --
    Cheers,
    Carlos E.R.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Dave Royal@dave@dave123royal.com to comp.mobile.android on Thu Jul 25 21:31:28 2024
    From Newsgroup: comp.mobile.android

    Malone <mslone@nospam.uk> Wrote in message:

    On Thu-25-Jul-2024 8:40 am, Dave Royal wrote:
    Malone <mslone@nospam.uk> Wrote in message:


    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 have links on my home page to .htm pages located on servers on the
    internet which always open with no problems. But .htm files located on
    my tablet seem to become inaccessible from the home page after a reboot
    until opened from within My Files - Downloads.

    Can someone with a better understanding of the Android OS than me
    explain what's going on?

    In the absence of an authoritative answer, and based on some
    googling (I am not a developer of Android apps), I'll offer a
    guess.

    I suspect that for the content URI in the shortcut (which is a
    pointer to a local resource, and AFAICS not the same as a file://
    URI) can only be accessed if Chrome has access to a Content
    Provider and for some reason (maybe a bug) there isn't one after
    a reboot. Perhaps accessing the content using My Files causes a
    Content Provider to be established, which can the be used by
    Chrome to access the content URI passed as a result of tapping
    the shortcut.

    <https://developer.android.com/guide/topics/providers/content-provider-basics>

    Thanks for that Dave. It sounds plausible to me but it seems I'm still
    going to have to go to My Files to reactive the shortcut after a reboot

    It was only a guess. I hoped an Android developer would confirm or
    refute it. I would have thought that passing a usable html
    shortcut to the the app that created it is the job of what in
    Linux would be called a 'desktop manager': this Samsung tablet
    uses 'One UI'. I've read that it's possible to use alternative
    DMs on some devices - maybe you can.

    On maybe you can open this file in Chrome using it's file location (file:///Internal storage/...) Firefox doesn't allow file:// URIs
    any more - does chrome?

    Opening local files in apps which did not create them (though in
    the case of your desktop shortcut Chrome /did/ create it) is IME
    the most baffling area of Android. I often want to open files (eg
    .abc music files) in editors and players which Android doesn't
    think I should and it's a constant battle.
    --
    Remove numerics from my email address.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Dave Royal@dave@dave123royal.com to comp.mobile.android on Thu Jul 25 23:06:08 2024
    From Newsgroup: comp.mobile.android

    Dave Royal <dave@dave123royal.com> Wrote in message:

    Malone <mslone@nospam.uk> Wrote in message:

    On Thu-25-Jul-2024 8:40 am, Dave Royal wrote:
    Malone <mslone@nospam.uk> Wrote in message:


    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 have links on my home page to .htm pages located on servers on the
    internet which always open with no problems. But .htm files located on >>>> my tablet seem to become inaccessible from the home page after a reboot >>>> until opened from within My Files - Downloads.

    Can someone with a better understanding of the Android OS than me
    explain what's going on?

    In the absence of an authoritative answer, and based on some
    googling (I am not a developer of Android apps), I'll offer a
    guess.

    I suspect that for the content URI in the shortcut (which is a
    pointer to a local resource, and AFAICS not the same as a file://
    URI) can only be accessed if Chrome has access to a Content
    Provider and for some reason (maybe a bug) there isn't one after
    a reboot. Perhaps accessing the content using My Files causes a
    Content Provider to be established, which can the be used by
    Chrome to access the content URI passed as a result of tapping
    the shortcut.

    <https://developer.android.com/guide/topics/providers/content-provider-basics>

    Thanks for that Dave. It sounds plausible to me but it seems I'm still
    going to have to go to My Files to reactive the shortcut after a reboot

    It was only a guess. I hoped an Android developer would confirm or
    refute it. I would have thought that passing a usable html
    shortcut to the the app that created it is the job of what in
    Linux would be called a 'desktop manager': this Samsung tablet
    uses 'One UI'. I've read that it's possible to use alternative
    DMs on some devices - maybe you can.

    On maybe you can open this file in Chrome using it's file location (file:///Internal storage/...) Firefox doesn't allow file:// URIs
    any more - does chrome?

    Opening local files in apps which did not create them (though in
    the case of your desktop shortcut Chrome /did/ create it) is IME
    the most baffling area of Android. I often want to open files (eg
    .abc music files) in editors and players which Android doesn't
    think I should and it's a constant battle.

    I tried to reproduce your case - Android 14 on a Samsung tablet.

    I can send a local html file from the 'My Files' app to Chrome
    (but not to Firefox) using 'Open with' and it displays as
    content://media/external/file/1000015925. But I see no way to
    'Add to home screen' in Chrome (which I can do for an ordinary
    URL in both Chrome and Firefox).

    But do see 'Add to home screen' in the 'My Files' app and the
    shortcut appears with a 'My Files' sub-icon. I suppose that's
    what you did. And that opens in Chrome, even though Firefox is my
    default browser. So My Files owns that content, and it seems it
    must open it first. I think my guess about it creating a Content
    Provider is correct-ish.

    Neither Firefox nor Chrome will open a file:/// URI (by design -
    CVE-2015-7186).

    Firefox will not open a content:// URI.
    --
    Remove numerics from my email address.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Malone@mslone@nospam.uk to comp.mobile.android on Fri Jul 26 14:27:57 2024
    From Newsgroup: comp.mobile.android

    On Fri-26-Jul-2024 10:06 am, Dave Royal wrote:
    Dave Royal <dave@dave123royal.com> Wrote in message:

    Malone <mslone@nospam.uk> Wrote in message:

    On Thu-25-Jul-2024 8:40 am, Dave Royal wrote:
    Malone <mslone@nospam.uk> Wrote in message:


    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 have links on my home page to .htm pages located on servers on the >>>>> internet which always open with no problems. But .htm files located on >>>>> my tablet seem to become inaccessible from the home page after a reboot >>>>> until opened from within My Files - Downloads.

    Can someone with a better understanding of the Android OS than me
    explain what's going on?

    In the absence of an authoritative answer, and based on some
    googling (I am not a developer of Android apps), I'll offer a
    guess.

    I suspect that for the content URI in the shortcut (which is a
    pointer to a local resource, and AFAICS not the same as a file://
    URI) can only be accessed if Chrome has access to a Content
    Provider and for some reason (maybe a bug) there isn't one after
    a reboot. Perhaps accessing the content using My Files causes a
    Content Provider to be established, which can the be used by
    Chrome to access the content URI passed as a result of tapping
    the shortcut.

    <https://developer.android.com/guide/topics/providers/content-provider-basics>

    Thanks for that Dave. It sounds plausible to me but it seems I'm still
    going to have to go to My Files to reactive the shortcut after a reboot

    It was only a guess. I hoped an Android developer would confirm or
    refute it. I would have thought that passing a usable html
    shortcut to the the app that created it is the job of what in
    Linux would be called a 'desktop manager': this Samsung tablet
    uses 'One UI'. I've read that it's possible to use alternative
    DMs on some devices - maybe you can.

    On maybe you can open this file in Chrome using it's file location
    (file:///Internal storage/...) Firefox doesn't allow file:// URIs
    any more - does chrome?

    Opening local files in apps which did not create them (though in
    the case of your desktop shortcut Chrome /did/ create it) is IME
    the most baffling area of Android. I often want to open files (eg
    .abc music files) in editors and players which Android doesn't
    think I should and it's a constant battle.

    I tried to reproduce your case - Android 14 on a Samsung tablet.

    I can send a local html file from the 'My Files' app to Chrome
    (but not to Firefox) using 'Open with' and it displays as
    content://media/external/file/1000015925. But I see no way to
    'Add to home screen' in Chrome (which I can do for an ordinary
    URL in both Chrome and Firefox).

    But do see 'Add to home screen' in the 'My Files' app and the
    shortcut appears with a 'My Files' sub-icon. I suppose that's
    what you did. And that opens in Chrome, even though Firefox is my
    default browser. So My Files owns that content, and it seems it
    must open it first. I think my guess about it creating a Content
    Provider is correct-ish.

    Neither Firefox nor Chrome will open a file:/// URI (by design -
    CVE-2015-7186).

    Firefox will not open a content:// URI.

    Yes, that's all consistent with what I experience. My Windows default
    browser is Firefox and at the outset I put that on my tablet. But I had problems with it, for reasons I can't remember, so got rid of it on the
    basis that Chrome was probably more Android-compatible although I
    consider it spyware.

    Having read your experiences I'm reassured it is not something to do
    with my settings and I'll need to open the file first from within My
    Files after any reboot (which isn't very often). I just find it a rather strange "feature" of the Android operating system.



    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Arno Welzel@usenet@arnowelzel.de to comp.mobile.android on Fri Jul 26 17:50:06 2024
    From Newsgroup: comp.mobile.android

    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 Welzel
    https://arnowelzel.de

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Arno Welzel@usenet@arnowelzel.de to comp.mobile.android on Fri Jul 26 18:01:03 2024
    From Newsgroup: comp.mobile.android

    Carlos E. R., 2024-07-25 21:56:

    On 2024-07-23 07:31, Malone wrote:

    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 seem to recall old bug aka feature that file:/// would not work in Android. Re firefox, probably.

    No, there is no global "file:///" mechanism in current Android versions
    for security reasons. The only files an app can access are the files
    within the app sandbox but nowhere else. Direct file access was
    discouraged in Android 4.4 and the use of the Storage Access Framework
    instead if direct file access is mandatory since Android 7.

    An app only sees URIs which *may* be connected to a file or folder on
    the device, but technically it is just a handle to some kind of data and
    which is provided by a storage provider. Apps like Google Drive,
    OneDrive, Nextclud etc. install storage providers which allow to access
    files on a server which don't have to stay on the device and will only
    get downloaded if needed.

    In addition, an app has to request permission for *every* URI it wants
    to access. This permission can be granted temporary (only lasting until
    the app is terminated or the device is rebootet) or it can be
    persistent, so the app has only to ask once and the permission will last
    as long as the app is installed on the device.

    So a browser could implement some mechanism to use the Storage Access
    Framework to open a "file" instead of a website and also ask to get a persistent permission for this - but I don't know any browser which
    implemented a "open a file using the storage access framework" feature.
    --
    Arno Welzel
    https://arnowelzel.de

    --- Synchronet 3.20a-Linux NewsLink 1.114