Loading Local Files with Browser Widget on Android

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Loading Local Files with Browser Widget on Android

Post by n.allan » Thu May 12, 2016 8:32 am

I just updated my app to use the browser widget instead of mobileControlCreate "browser". I am no unable to load links to local files.
The files are copied in the standalone application settings and they were accessible by using the link with the old browser.

"file:" & specialFolderPath("engine") & "/info.html"

The browser widget is working because I can load Internet links no problem.

I have tried

set the URL of widget "Browser" to "file:" & specialFolderPath("engine") & "/info.html"
set the URL of widget "Browser" to "file:" & specialFolderPath("documents") & "/info.html"

The browser widget just says "ERR_FILE_NOT_FOUND"

It works in the IDE but not on Android. What am I missing here?

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Loading Local Files with Browser Widget on Android

Post by Klaus » Thu May 12, 2016 10:11 am

Hi n.allan,

shouldn't this be:
...
set the URL of widget "Browser" to ("file://" & specialFolderPath("resources") & "/info.html")
...

Some general hints:
1. Always use brackets when concantenating strings for object and or pathnames!
May work here and there, but will fail when you least exspect it!

2. Local files need 2 extra slashes in the URL, see above!

3. Files copied to your standalone via the "Copy files" tab in the standalone builder settings will be found in -> specialfolderpath("resources")
Which is the same as the engine folder on mobile, but for crossplatform reasons stick to RESOURCES. :D

Hope that helps.


Best

Klaus

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Re: Loading Local Files with Browser Widget on Android

Post by n.allan » Thu May 12, 2016 1:57 pm

Still no dice.

I also tried removing 1 slash to see if the path is being fussy.

set the url of widget "Browser" to ("file:/" & specialFolderPath("resources") & "/info.html")

still ERR_FILE_NOT_FOUND

The file is definitely there in the apk bundle.

I'm a bit bummed I deleted my old code as it worked fine with mobileControlCreate(), I just fancied using the browser widget. Never mind backwards we go again.

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Re: Loading Local Files with Browser Widget on Android

Post by n.allan » Thu May 12, 2016 2:52 pm

Yup all works OK with the old browser control on both my devices. 1 slash or 2 slashes. I might even file bug report. It might be a bug on the specialFolderPath() function itself. I did try displaying the url in a message box before setting the browser url but there is no difference between what I am using with the old browser and the new widget. (I wouldn't even know what the correct path format for Android was anyway)

I also notice on windows that...

specialFolderPath("engine") returns the path with back slashes whilst specialFolderPath("documents") returns forward slashes. I know these can be platform dependent but it might be better to standardise this as windows understands both (in LiveCode anyway)

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Loading Local Files with Browser Widget on Android

Post by Klaus » Thu May 12, 2016 3:15 pm

Hi n.allen,

hm, then I consider this a bug, same for backward slashes in specialfolderpath("engine")!
Internally LC ALWAYS uses the UNIX forward SLASH as a pathdelimiter on whatever platform!

Please consider to report this as a bug here: http://quality.runrev.com
Thanks!


Best

Klaus

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Re: Loading Local Files with Browser Widget on Android

Post by n.allan » Thu May 12, 2016 5:00 pm


KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: Loading Local Files with Browser Widget on Android

Post by KimD » Tue Sep 06, 2016 1:29 am

With regard to the original post - I've managed to get local html files working in the browser widget (on Windows IDE, Android simulator, and real Android device), but I had to use slightly different code depending on the environment.

Switch the environment
Case "mobile"
set the URL of widget "Browser" to empty
set the htmltext of widget "Browser" to URL("file:" & specialFolderPath("engine") & "/TestLinks.html")
Break
Case "development"
set the URL of widget "Browser" to "file:" & specialFolderPath("engine") & "/TestLinks.html"
Break
end Switch

Kim (on LC8.0.2)

dbeugeling
Posts: 12
Joined: Thu Feb 12, 2015 12:22 pm

Re: Loading Local Files with Browser Widget on Android

Post by dbeugeling » Wed Mar 15, 2017 10:21 pm

Thank you Kim,
unfortunately, I could not get it to work, but I found out, that you need some more //.
See my upload. (You pick your own user path and picture, please).

Dick
Attachments
Browsertest2.livecode.zip
(1.24 KiB) Downloaded 296 times
Last edited by dbeugeling on Sun Mar 19, 2017 3:56 pm, edited 1 time in total.

Post Reply

Return to “Android Deployment”