Reputation: 4417
I saw that you can call from JS to function of PhoneGap on the following link:
Communication between Android Java and Phonegap Javascript?
My question is if you can in the opposite way?
From PhoneGap to call the JS function
Upvotes: 1
Views: 1133
Reputation: 321
If I were you, I would read this tutorial on how to implement a JavaScript interface on Android, and after this you should be able to call a JavaScript functions either way.
for example from your code: webViewName.loadUrl("javascript:somemethod()");
I believe you can implement this behavior in PhoneGap. Tell me if i'm wrong!
That's what i think off the top of my head. :)
Upvotes: 4
Reputation: 252
in android, the DroidGap class(one which is base class for activity for a phonegap app) provides method "sendJavascript()" to execute javascript. this methods is available for activity extending the DroidGap class, something like this -
public class MainActivity extends DroidGap {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MainActivity.this.sendJavascript("var myInt=10;");
super.loadUrl("file:///android_asset/www/index.html");
}
}
Upvotes: 1