I am working on Android app with webview using javascript. I have an method which is returning Arraylist, i want to access it in my javascript. I know how to handle a single string returning from a method in javascript ,but i want to know about how to handle a Dataobject of arraylist in javascript.
1 Answer
There really isn't a good way to translate Java objects (other than primitives and Strings) across the Javascript bridge. What you probably want to do is convert your ArrayList into a JSON array and then pass the serialized representation over to the JavaScript code. You can then eval it or use JSON.parse to convert it into a JavaScript array.
3 Comments
ARV
Thanx Femi...Will u please provide me a good resource or documentation to do it...
Femi
Unfortunately I really don't have good documentation: the little I've done with this isn't really something I can share. I'd suggest taking a look at the source for the PhoneGap Android project at phonegap.com: they do extensive JavaScript bridge work.
dragon
Array to JSON: stackoverflow.com/questions/5166592/…