0

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.

ARV
  • 395
  • 2
  • 6
  • 19

1 Answers1

0

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.

Femi
  • 64,273
  • 8
  • 118
  • 148
  • Thanx Femi...Will u please provide me a good resource or documentation to do it... – ARV Aug 07 '11 at 06:08
  • 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 http://www.phonegap.com/: they do extensive JavaScript bridge work. – Femi Aug 07 '11 at 06:11
  • Array to JSON: http://stackoverflow.com/questions/5166592/convert-normal-java-array-or-arraylist-to-json-array-in-android – dragon Oct 28 '12 at 00:27