Page 1 of 1
Viewing Local file in browser (Android)
Posted: Wed Sep 18, 2013 4:10 am
by genie
Hello!
How can I view local file in browser for Android? Anyone?
In my script, I have created some html, stored it an a variable, and stored the entire html as map.html under Documents.
Code: Select all
put "file:///"&specialFolderPath("engine") & "/Images/disneyMap.jpg" & quote & "/>" after newHTML
write newHTML to file specialFolderPath("Documents")&"/map.html"
Under copy files, I have included all the contents of Images folder (including disneyMap.jpg)
...but disneyMap.jpg does not display in Android. It works perfectly on iOS.
So, I am thinking it's probably files and folder issue. There might be something different as where Android saves Engine files that I do not know.
I have tried...
Code: Select all
"file://"&specialFolderPath("engine") & "/Images/disneyMap.jpg"
specialFolderPath("engine") & "/Images/disneyMap.jpg"
but have not been successful.
Please advise....
Thanks,
Genie
Re: Viewing Local file in browser (Android)
Posted: Wed Sep 18, 2013 6:20 am
by Simon
HI Genie,
I could only get it to work by moving the image to the documents folder.
I'm sure there is a way to link to the engine... must be.
Code: Select all
on mouseUp
put URL ("binfile:" & specialFolderPath("engine") & "/Images/disneyMap.jpg") into URL ("binfile:" & specialFolderPath("documents") & "/disneyMap.jpg")
put"<!DOCTYPE html PUBLIC ""e&"-//W3C//DTD XHTML 1.0 Transitional//EN""e&" ""e&"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""e&">" & cr & \
"<html xmlns=""e&"http://www.w3.org/1999/xhtml""e&">" & cr & \
"<head>" & cr & \
"<meta http-equiv=""e&"Content-Type""e&" content=""e&"text/html; charset=utf-8""e&" />" & cr & \
"<title>Untitled Document</title>" & cr & \
"</head>" & cr & \
"" & cr & \
"<body>" & cr & \
"<p>Hi there Genie</p>" & cr & \
"<p><img src=""e&"disneyMap.jpg""e&" width=""e&"360""e&" height=""e&"480""e&" /></p>" & cr & \
"</body>" & cr & \
"</html>" into tFile
put tFile into url ("file:" & specialFolderPath("documents") & slash & "map.html")
wait 1 tick
launch url ("file:" & specialFolderPath("documents") & slash & "map.html")
end mouseUp
If you want me to continue investigating just say.
It's Fun!
Simon
Re: Viewing Local file in browser (Android)
Posted: Wed Sep 18, 2013 6:33 am
by genie
Thanks Simon for investing time...

Really appreciate it.
I know engine is not writable but should be accessible...but not from browser? Well, I'm gonna try to move the image to Documents then.
Thanks,
Genie
Re: Viewing Local file in browser (Android)
Posted: Wed Sep 18, 2013 7:57 am
by genie
Hello Simon!
Were you able to open map.html in a browser?
Code: Select all
launch url ("file:" & specialFolderPath("documents") & slash & "map.html")
Using html viewer, I get:
"Webpage not available.
The webpage at
content://com.android.htmlfileprovider/data/data/**app identifier**/files/map.html?text/html might be temporarily down or...blah blah"
Regards,
Genie
Re: Viewing Local file in browser (Android)
Posted: Wed Sep 18, 2013 8:03 am
by Simon
Hi Genie,
Using the code I posted above I was able to.

(my image name was actually different but that's easy).
Simon
Re: Viewing Local file in browser (Android)
Posted: Wed Sep 18, 2013 8:11 am
by genie
I wonder why I can't launch it... but nevermind..

Your idea of transferring the image to the documents WORKED!!!
I had it working on my in-app browser using ...
Code: Select all
mobileControlSet sBrowserId, "url", (theBrowserURL)
Thanks! You saved my day!
Regards,
Genie
Re: Viewing Local file in browser (Android)
Posted: Wed Sep 18, 2013 8:16 am
by Simon
Here is my fun stack so that you can use dreamweaver or whichever tool you use to create html and then get it into liveCode.
Just copy paste and press the button
Simon
Re: Viewing Local file in browser (Android)
Posted: Wed Sep 18, 2013 8:33 am
by genie
Simon wrote:Here is my fun stack so that you can use dreamweaver or whichever tool you use to create html and then get it into liveCode.
Just copy paste and press the button

Thank you!