1

I'm currently working on an Android application that uses Phonegap, and I would like to be able to "share" data between my Java code and my javascript code. Essentially, the user experience exists among the various html and javascript pages I have, but there are certain strings I want to pass to a javascript function when it is called from within the html page it is tied to.

Is this possible? I've seen some things about Applets, but don't fully understand what that means for my code. Assuming I can save the string I want as a String object somewhere in my java code, can I tell my javascript function to go find it, grab it, convert it to a javascript string object, and then work with it normally from there?

Thank you!

Dan
  • 212
  • 1
  • 6
  • 12
  • One stackoverflow search away :) http://stackoverflow.com/questions/15653441/insert-a-java-string-into-phonegap-javascript – Bogdan M. Jul 28 '14 at 14:47
  • Hey @BogdanM. thank you for your response. Unfortunately, that approach doesn't seem to work for me. The problem is that my string may not be set until after the file url is loaded, so appending it as a parameter won't be practical. It doesn't need to pass instantly, but as soon as it gets set to a value, I want to either pass it or be able to access it via javascript code. – Dan Jul 28 '14 at 15:07
  • 1
    Either write a phonegap plugin and make the data available through the plugin, or do it the hacky way like [this](http://stackoverflow.com/questions/20531184/execute-phonegap-function-from-android-java/20531652#20531652) – Uncharted Space Jul 28 '14 at 19:35

1 Answers1

0

Create a phonegap plugin to set and retreive a value.

Use the same phonegap plugin in javascript.

snehatulsi
  • 251
  • 1
  • 12