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!

3
  • One stackoverflow search away :) stackoverflow.com/questions/15653441/… Commented Jul 28, 2014 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. Commented Jul 28, 2014 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 Commented Jul 28, 2014 at 19:35

1 Answer 1

0

Create a phonegap plugin to set and retreive a value.

Use the same phonegap plugin in javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.