Viewing Local file in browser (Android)

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Viewing Local file in browser (Android)

Post by genie » Wed Sep 18, 2013 4:10 am

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)

Code: Select all

Images/*
...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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Viewing Local file in browser (Android)

Post by Simon » Wed Sep 18, 2013 6:20 am

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 "&quote&"-//W3C//DTD XHTML 1.0 Transitional//EN"&quote&" "&quote&"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&quote&">" & cr & \
"<html xmlns="&quote&"http://www.w3.org/1999/xhtml"&quote&">" & cr & \
"<head>" & cr & \
"<meta http-equiv="&quote&"Content-Type"&quote&" content="&quote&"text/html; charset=utf-8"&quote&" />" & cr & \
"<title>Untitled Document</title>" & cr & \
"</head>" & cr & \
"" & cr & \
"<body>" & cr & \
"<p>Hi there Genie</p>" & cr & \
"<p><img src="&quote&"disneyMap.jpg"&quote&" width="&quote&"360"&quote&" height="&quote&"480"&quote&" /></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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Viewing Local file in browser (Android)

Post by genie » Wed Sep 18, 2013 6:33 am

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

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Viewing Local file in browser (Android)

Post by genie » Wed Sep 18, 2013 7:57 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Viewing Local file in browser (Android)

Post by Simon » Wed Sep 18, 2013 8:03 am

Hi Genie,
Using the code I posted above I was able to. :)
(my image name was actually different but that's easy).

Simon

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Viewing Local file in browser (Android)

Post by genie » Wed Sep 18, 2013 8:11 am

I wonder why I can't launch it... but nevermind.. :) Your idea of transferring the image to the documents WORKED!!! :D

I had it working on my in-app browser using ...

Code: Select all

mobileControlSet sBrowserId, "url", (theBrowserURL)
Thanks! You saved my day!


Regards,
Genie

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Viewing Local file in browser (Android)

Post by Simon » Wed Sep 18, 2013 8:16 am

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
Attachments
infamous_quotes.zip
LC 6.1
(838 Bytes) Downloaded 404 times
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Viewing Local file in browser (Android)

Post by genie » Wed Sep 18, 2013 8:33 am

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!

Post Reply