Java – Call JavaScript from Eclipse for PhoneGap

Call JavaScript from Eclipse for PhoneGap… here is a solution to the problem.

Call JavaScript from Eclipse for PhoneGap

I’m trying to load a website with Phonegap on Android with the following code:

   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setBooleanProperty("loadInWebView", true);
    super.loadUrl("http://arriva.com.mt");

}

How do I execute a local JavaScript file on WebView?

Solution

I ran into this issue but eventually solved it myself. In your activity you have
super.loadUrl("javascript:yourFunction()"); In your code – make sure you have a window-scoped function to trigger window. When you use PhoneGap, I assume that JavaScript is enabled in the web View. If not, you need to enable it as well, and you may find my post useful to know about it.

Calling javascript functions in a webview from activity class

HTH

Related Problems and Solutions