Discussion Forums  >  WebViews and HTML for Mobile

Replies: 20    Views: 266

WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
12/07/13 08:37 AM (10 years ago)

HTML / Javascript for Android help needed.

Have a little calculator built with HTML and Javascript that runs fine in a browser and on iOS, but it doesn't do anything in Android... https://dl.dropboxusercontent.com/u/66391742/mcgCalc.html Anyone? Thanks in advance, Tim
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
12/07/13 09:03 AM (10 years ago)
I don't do a whole lot with android, but did you include the .js file in your build, or does it reference it online? I am guessing you see the layout, but don't get any interaction?
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
12/07/13 09:24 AM (10 years ago)
It's a HTML doc with script in the doc head. Works in everything but Android. No results on Android
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
12/07/13 09:30 AM (10 years ago)
Well, I guess I'm going to answer my own question again... sort of. It will run in Android from a custom URL screen pointing to that file on dropbox. So I guess I can just launch it from a local URL... This makes me believe though that there is a simple fix for it not working in the webview. Tim
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
12/07/13 09:39 AM (10 years ago)
Yea, I was going to tell you to try a custom URL. For some reason they act differently. Jim
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
12/07/13 09:41 AM (10 years ago)
So, how can I make this work while the device has no connectivity? HTML Pro plugin maybe? Chris? Bueller... Bueller.... Bueller....
 
tb
buzztouch Evangelist
Profile
Posts: 2050
Reg: Nov 03, 2011
Oxford
32,300
like
12/07/13 09:54 AM (10 years ago)
HTML Pro isn't a HTML page. HTML Pro just gives you a link to the other app pages, which you can use in the HTML screens
 
Caslor
Android Fan
Profile
Posts: 191
Reg: Jul 26, 2013
athens
1,910
like
12/07/13 11:42 AM (10 years ago)
Hi my friend i just save your full html page and make an experiment by my own i used BTv2 and not Btv3 i tried 3 options custom html/text custom url html doc all worked fine as i was connected to the internet when i disable wifi the only option that worked off line was the html doc in off line mode in the custom url couldnt open the page (your html file online) in custom html/text (i placed your code in the editors panel in BT) i could see the form , place numbers but couldnt solve (refresh button worked) in html doc i place the html file and java scripts all in the same folder BT_Docs this is the solution (if you choose to work with BTv2 because in BTv3 this plugin works in a differnt way.. doesnt open the files before ask you what program to use to open them) hope help you
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
12/07/13 12:03 PM (10 years ago)
Like Caslor stated above, include the files in you project, then point to that file in your custom URL. I have not done this in 3.0, but my last android app had a ton of pages set up like this.
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
12/07/13 01:22 PM (10 years ago)
I tried it in a BT 2 app, put the HTML file in BT/docs and used an HTML doc screen, in Android it doesn't work (this all tried before my first post). Are you saying that it does work for you? Tim
 
Caslor
Android Fan
Profile
Posts: 191
Reg: Jul 26, 2013
athens
1,910
like
12/07/13 01:29 PM (10 years ago)
yes worked fine.. but the html file and the javascripts files must be at the same folder /BT_Docs and not only the html file and the javasripts to sub folder... this will not work
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
12/07/13 01:35 PM (10 years ago)
There is only one HTML file with the script in the head. Are you sure you tried the linked file? I'll try it again, maybe I missed something. Thanks
 
Caslor
Android Fan
Profile
Posts: 191
Reg: Jul 26, 2013
athens
1,910
like
12/07/13 01:54 PM (10 years ago)
ok i download it again.. only the .htm file.. place it in the project and compile it - run it from eclipse to my mobile worked fine !! (i am jealous your skills with javascript ;) ) Notice : you must use small latters for the name of your file.. and without spaces test.htm (that the name i used for your file...)
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
12/07/13 02:05 PM (10 years ago)
Awesome. Thanks. Not sure what I did the first time.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
12/07/13 02:14 PM (10 years ago)
Hi Tim I have used javascript in ios and android and put the js in the project build, so it works offline in V2.1.9 projects. What works for me is the following recipe :- First, I have the JavaScript and css in a subdirectory and not all in the html. This way, the same works in android and IOS apps. When you copy files into an xcode project, a box pops up to choose options for adding the files. When I drag in the folder with the JavaScript and css, I tick 'Create folder references for any added folders'. When I drag in the html file, I tick 'Create groups for any added folders' I have only had BT 3.0 working for a couple of hours, this still works for ios but haven't tried this in android 3 yet. Give it go, it should work for you too. Cheers, Alan
 
Caslor
Android Fan
Profile
Posts: 191
Reg: Jul 26, 2013
athens
1,910
like
12/07/13 02:22 PM (10 years ago)
AlamMac in version3 the html doc plugin doesnt work as it worked in version 2 it asks always to choose the right native application to open the file.. (like it was for pdf doc, word doc plugins) from relative topics about that issue.. i saw somewhere that there is a thinking to change it again as it was for version 2 (i hope)
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
12/07/13 03:20 PM (10 years ago)
On Android, there was a mod that smug wimp posted a while ago that gets around that. I'll see if I can find it. iOS works as before. Alan
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
12/07/13 03:35 PM (10 years ago)
 
Caslor
Android Fan
Profile
Posts: 191
Reg: Jul 26, 2013
athens
1,910
like
12/07/13 03:50 PM (10 years ago)
yes i have seen that but didnt manage to adjust it to work for me so i left the V3 and continue to V2 for the moment :) Maybe if someone make it more easy to add it in the projects will try again :) of course it is a benefit to continue in V2 as most of the devices around the world are still i lower version of android than V4
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
01/24/14 03:47 AM (10 years ago)
Update - The approach I outlined for embedding javascript into a project does work and is good for IOS and Android in BT 3.0. The problem is the HTML Doc plugin doesn't seem to work with JavaScript on Android. You can use the Custom URL plugin instead and reference the html file in the project. Custom URL document location notation is file:///android_asset/BT_Docs/myfile.html Or if you want it to work just as it used to be in BT 2.1.9, use the HTML Pro plugin and the same approach works identically for both Android and IOS.
 
kitkatman
Aspiring developer
Profile
Posts: 24
Reg: Jul 25, 2012
Lagos
1,340
like
04/09/14 07:16 AM (10 years ago)
I am trying to use this method to create a jquery gallery in android an project version 3. Is it possible to use the htmlpro plugin to link to a html page locally? Or use customURL(not sure it views local files)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.