reading an html file that was added to the media list

4,087 views
Skip to first unread message

Gary

unread,
Aug 3, 2012, 9:01:16 AM8/3/12
to ai...@googlegroups.com
Howdy

You can load a html file in with your other Media. Once it is there, you can read it with the WebViewer with this url
  file:///mnt/sdcard/AppInventor/assets/test.html

Source and pictures soon

Gary


Gary

unread,
Aug 3, 2012, 9:13:53 AM8/3/12
to ai...@googlegroups.com
https://plus.google.com/u/0/100632474408684291425/posts/FyDGRXhkuPy

I loaded the html file like we load other media files. Then start adb shell.
On my Linux PC I changed directory to the Android sdk and got into the shell on the device where I installed the app
  cd opt/android-sdk-linux_r20/android-sdk-linux/platform-tools
  ./adb shell

you location may differ

from there I looked in /mnt/sdcard/AppInventor/assets and there was my html file

This gives you a way to get html locally. It is not a full up web server, but it will do the trick for html that does not need a web server.

Gary

unread,
Aug 3, 2012, 9:37:50 AM8/3/12
to ai...@googlegroups.com
and while we are talking about it...


"Google Play currently requires that your APK file be no more than 50MB. "
...
"Google Play hosts the expansion files for your application and serves them to the device at no cost to you."

One of my hopes is that we will be able to have expansion files by the time I get to V1.5. That gives us 4GB. wow

and I am working with OAuth. I have hopes that we can use Google Drive to put stuff... in the cloud and then get at it with Drive running on the device. I just tested

load an html file on my pc (I got the file from a windows partition on linux) into Google Drive
and view it on my phone

OAuth lets us do more with services that have the nice REST interfaces like Google Drive.

Taifun

unread,
Aug 3, 2012, 9:38:47 AM8/3/12
to ai...@googlegroups.com
as already mentioned here https://groups.google.com/d/msg/appinventor/gY8B6Bbk3Ug/wXoWdPTx-y4J

html is not supported to upload as media file to AI, see the supported types here: http://beta.appinventor.mit.edu/learn/reference/other/media.html

to that directory you mentioned you only have access during development... the images you can display directly without filepath, correct? but the html files not, this is why it does not work anymore after packaging and running on another device, you have to access the files from inside AI (i.e. without filepath), what you are doing is to access them from outside

there is only this way: download the files form the internet on first run...

Taifun
puravidaapps.com

Gary

unread,
Aug 3, 2012, 9:53:31 AM8/3/12
to ai...@googlegroups.com

On Friday, August 3, 2012 8:38:47 AM UTC-5, Taifun wrote:
as already mentioned here https://groups.google.com/d/msg/appinventor/gY8B6Bbk3Ug/wXoWdPTx-y4J

I do not read that group. Thanks for the pointer.
 


html is not supported to upload as media file to AI, see the supported types here: http://beta.appinventor.mit.edu/learn/reference/other/media.html

to that directory you mentioned you only have access during development... the images you can display directly without filepath, correct? but the html files not, this is why it does not work anymore after packaging and running on another device, you have to access the files from inside AI (i.e. without filepath), what you are doing is to access them from outside

I just looked and the file is still there
but
the app did not come up.

hmmm

Taifun

unread,
Aug 3, 2012, 9:55:25 AM8/3/12
to ai...@googlegroups.com
of course you also can test it on the same device, but in this case do not forget to delete the assets in the mentioned folder, else you will access these development files from your packaged app...
Taifun


Gary

unread,
Aug 3, 2012, 10:11:41 AM8/3/12
to ai...@googlegroups.com
It did not come up when I tried the installed app
the app did not show anything???

I tried activity starter also. no luck

hmmm

no spare time
back to what I was doing originally - OAuth etc.

Gary

Gary

unread,
Aug 3, 2012, 10:58:35 AM8/3/12
to ai...@googlegroups.com
We have source...

I think being able to get at files locally is a good idea.
That sounds like a big security hole, 
but very useful.

The expansion files may be the way to go. Back to that.

Gary

Gary

unread,
Aug 4, 2012, 7:51:36 AM8/4/12
to ai...@googlegroups.com
change the url to file:///android_asset/test.html

as best I can tell ;-) that reads the content of your app's asset folder.




Taifun

unread,
Aug 4, 2012, 11:02:54 AM8/4/12
to ai...@googlegroups.com
it works! you are a genius!
 see also here https://groups.google.com/d/msg/appinventor/gY8B6Bbk3Ug/FCQZgwvyUNkJ
Taifun

Gary

unread,
Aug 4, 2012, 12:46:30 PM8/4/12
to ai...@googlegroups.com
:-)

It took a team, Scott and the Canadian lady to get us going, me to come up with the solution that works great in development, Taifun to point out it did NOT work when you install an apk clean and me to be thorough and do some more looking!

Sooooo

This works in development
  file:///mnt/sdcard/AppInventor/assets/test.html
because App Inventor puts the file in an assets folder when it loads

and this works from the apk
  file:///android_asset/test.html
because like all good android apps, it's assets are in the apk and the android browser can get at them using that url.

-----
and 
with great power comes great responsibility 

It is a nice technique for putting good docs up.
I want to look into the WebView on Android with Java and Javascript talking with each other (after V1.5)

It may open up a security hole???

and the page is not on a web server. Lot's of stuff will work, some may not. (something to test after V2.0?)

so,
spread the word
let folks know they can follow up in the ai4a getting set up and connected group https://groups.google.com/forum/?fromgroups#!forum/usgsuacwai


and let us know here how it works for you.

Gary

Taifun

unread,
Aug 4, 2012, 1:37:09 PM8/4/12
to ai...@googlegroups.com
It may open up a security hole???
why? could you explain?
Taifun

Dennis A.

unread,
Aug 4, 2012, 4:27:03 PM8/4/12
to ai...@googlegroups.com
worth reposting here...

If this is doing what I think it's doing..
.. it makes me dizzy thinking about what I could be thinking doing with this..
;-)

downloaded to my GN 7 tablet... works fine..

congrats to you guys.. ya'll are amazing...

Dennis

 

Taifun

unread,
Sep 8, 2012, 4:04:43 PM9/8/12
to ai...@googlegroups.com
file:///android_asset/test.html
-> this works on all devices

file:///android_asset/test.html#down
file:///android_asset/test.html?parameter
-> both work only on devices with Android 2.x, but not on Android 3.x, 4.x, see also here https://groups.google.com/d/topic/ai4a/fCCfLsRRnXA/discussion

why is that? anybody has another idea how to pass parameters to the embedded HTML/JavaScript which also works with Android 3.x/4.x?
Taifun

attached a simple HTML example which tries to jump directly to an anchor in the document

HTML_V2.zip
HTML_V2.apk
Message has been deleted

Scott Ferguson

unread,
Sep 8, 2012, 6:51:47 PM9/8/12
to ai...@googlegroups.com
I can confirm that on the ASUS Transformer TF-101, Android 4.x that both a) file:///android_asset/hello.html#down and  b) file://localhost/android_asset/hello.html#down throw the 'Webpage not available' error for the packaged apk,
and  file://localhost/android_asset/hello.html  does work when you leave off the #down bookmark link. 

Taifun

unread,
Sep 9, 2012, 1:13:21 PM9/9/12
to ai...@googlegroups.com
as a workaround we can download the html file on first run of the app, see here http://puravidaapps.com/table2.php
Taifun

Scott Ferguson

unread,
Sep 9, 2012, 9:35:32 PM9/9/12
to ai...@googlegroups.com
Nice solution that should work with the #down bookmark suffix as well.
---

Jomebrew

unread,
Sep 9, 2012, 9:39:03 PM9/9/12
to ai...@googlegroups.com
I found that downloading the file requires me to calculate some sort of hash on the file to be sure it is intact and not corrupt.
Reply all
Reply to author
Forward
0 new messages