Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
11/29/12 08:49 PM (13 years ago)

reference .js files in eclipse

I am working with javascript files (Custom HTML & HTML Docs / self hosted) in Android and I can not get my .js files to work? My images do not show up either? I have the .js file in BT_Docs and my images in res/drawable/ Within HTML in Android do I need to specify something other then just the name for the source? I am using the same files I used in iOS and they worked perfectly?
 
Mackimack
Apple Fan
Profile
Posts: 481
Reg: Dec 30, 2010
Sweden
14,310
like
11/29/12 11:32 PM (13 years ago)
Hi crown. I think you need to have all the fils in your docs folder. .js html and the image all in the same folder.
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
11/30/12 02:05 AM (13 years ago)
Yes I put all my files in the same folder and it works.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/30/12 06:12 AM (13 years ago)
I always use the customURL plugin for any html, then first thing I do with the project in eclipse is delete the bt folders in assets, then treat the assets folder as I would a regular website directory. Works for me.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
11/30/12 07:20 AM (13 years ago)
Great tip @raveyd! @Crown Solutions: I just started working with js files, so I was wondering, you using a script?
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
11/30/12 07:27 AM (13 years ago)
Thanks everyone, I will give it a try tonight. LA- I am using a script that allows me to collapse and expand lists. Fairly simple, and allows for a little interaction within the HMTL.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
11/30/12 07:29 AM (13 years ago)
Hey @Crown Solutions, Thank you...js pretty stable? LA
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
11/30/12 07:33 AM (13 years ago)
So far in iOS it has worked well. This is my first attempt in Android. I will let you know how it goes.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
11/30/12 07:35 AM (13 years ago)
Thank you! LA
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/30/12 07:40 AM (13 years ago)
@LA, any sort of js files should work ok with android. Whichever ones you use, try to find a .min version, this will usually be optimized for mobile, but it's not a requirement. I find that the less files, or references to js files in the html file, there are, the more efficient the webpage is in an app.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
11/30/12 11:32 AM (13 years ago)
ok thanks @raveyd. LA
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
11/30/12 07:26 PM (13 years ago)
I must have messed something else up here. I tried putting them all in the docs folder, and no go. I also tried just having them in the the assets folder still no luck. I also tried putting them in the assets folder and referenced them from a URL. @raveyd, when you enter the URL do you do something like this? /assets/nameofdoc.html I tried this and had no luck. I am trying on both a physical device and an emulator.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
12/01/12 07:49 AM (13 years ago)
Hey @Crown Solutions, If your keeping your docs folder then it would be /assets/docs/nameoffile and has to be all lower case in Android. LA
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
12/01/12 07:55 AM (13 years ago)
Hey @raveyd or @Crown Solutions: Can you give me a good resource about .js files please? LA
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
12/01/12 03:35 PM (13 years ago)
@Crown Solutions - Using a customURL plugin, I always reference files as file:///android_asset/ for example, I posted an image gallery a while ago and the url to open the gallery was file:///android_asset/gallery/gallery/gallery.html - just like a regular website directory. Hope that helps. @LA - Sorry mate, nothing springs to mind. If I need something I just have a dig around google until I find something to fit the need. Although I always find stackoverflow a really useful resource - good replies usually link to something interesting.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
12/01/12 03:42 PM (13 years ago)
Yes I was just looking there..lol thank you. LA
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
12/02/12 05:49 PM (13 years ago)
Thanks, got this working using raveyd's method. LA- I found this one with Google as well.
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
05/14/13 11:21 AM (12 years ago)
Hey all I have a js and css file working great in IOS. when i try in android i put all the files into the btdoc folder and i cant get it to work. ARGGG. Any tips?
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
05/14/13 12:57 PM (12 years ago)
Hi Feraco You're going to have to use a WebChromeClient instead of a WebView in your customURL plugin, or your HTMLDoc plugin, and import the needed libraries that Eclipse tells you to. So Around line 130 in the plugins, instead of setting the WEBVIEW, you would need to do something like this: webView.setWebChromeClient(new WebChromeClient(){ and then some minor changes to make it all work. Hope this works out for you...
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
05/14/13 01:23 PM (12 years ago)
Ok I got it working just changing the root of the js and CSS files to file:///android_asset/ Just like raveyd said. I have this working perfectly for iOS. It's a touch screen calendar where you can input text when a date is touched for some reason in the simulator for android it is not responding to touch. Hmmmm
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
05/14/13 09:39 PM (12 years ago)
Did you change the code? The default install won't let you run javascript in Android. There are other ways of referencing js but I believe in the long run the easiest would be the one I posted.
 

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.