file:///android_asset no longer working

1,521 views
Skip to first unread message

Aurelien M

unread,
Dec 9, 2016, 3:43:15 PM12/9/16
to App Inventor for All
Hi everyone

I am trying this trick of loading an HTML page from my assets into a WebViewer component but it fails. I've even written a file explorer type of interface to browse the directory structure (using TaifunFile.FileListASync) but there is no such path.

Reading on the Android documentation, it seems all assets are locked to the WebViewer unless the setAllowFileAccess variable is set to true. It was true by default prior to ICS but it's set to false by default from JellyBean onward.

See here for more details.


Does anyone have a suggestion for load a local HTML file assuming the user will not have an Internet connection ever (except at install time)?

thanks a bunch!
A M

Taifun

unread,
Dec 9, 2016, 6:02:37 PM12/9/16
to ai...@googlegroups.com
the webviewer can load a html file from the assets or from the internet, but not from the sdcard 
Taifun

Aurelien M

unread,
Dec 9, 2016, 6:52:16 PM12/9/16
to ai...@googlegroups.com
Thank you for the response, but my point was that it doesn't work from the assets. Loading anything from file:///android _asset/ fails on modern android devices...

A M

On Dec 9, 2016 18:02, "Taifun" <taifu...@gmail.com> wrote:
you only can load a html file from the assets or from the internet, but not from the sdcard 
Taifun

--
You received this message because you are subscribed to a topic in the Google Groups "App Inventor for All" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ai4a/3yUjhwfHRN4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ai4a+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Taifun

unread,
Dec 9, 2016, 6:57:17 PM12/9/16
to App Inventor for All
this still works, at least on a Nexus 5X running Android 7
you might want to provide a screenshot of your relevant blocks

Yes, you also can upload html files as assets into App Inventor! There is only one special thing to consider: During development, you have to use the development path to the embedded html document:

file:///mnt/sdcard/AppInventor/assets/<NAME OF YOUR HTML FILE>.html


Before packaging the app, use the production path.

file:///android_asset/<NAME OF YOUR HTML FILE>.html


Taifun

Aurelien M

unread,
Dec 9, 2016, 7:27:47 PM12/9/16
to ai...@googlegroups.com
that's very odd. Here's my code that gets activated when a button is pushed. It tries to determine if a file:///android_asset/database.html file exists, if so, use it, otherwise use the development path.

Everytime I test on the emulator, it loads the development path as expected, however, when I run the code on my tablet (Lenovo Yoga Tab3 with Android 5.1.1), it still tries to use the development path (I have another Notifier element indicating what has been loaded)

I can't see any problem with my code...

thx
A M

--
Screenshot from 2016-12-09 19-21-33.png

Taifun

unread,
Dec 10, 2016, 10:25:22 AM12/10/16
to ai...@googlegroups.com
Everytime I test on the emulator, it loads the development path as expected, however, when I run the code on my tablet (Lenovo Yoga Tab3 with Android 5.1.1), it still tries to use the development path (I have another Notifier element indicating what has been loaded)
did you try that after building the app? 
usually I use a flag like this (taken from the table exmaple)


to make things easier, I also could provide a new method in an extension, which could return true or false in case an app is running in the companion app or not... in case you like to be the sponsor of that method, let me know

Taifun

Reply all
Reply to author
Forward
0 new messages