I try to call a method in java from javascript, but this does not happen when I run the application in the emulator, the application stops when it is supposed to call the method in java.
here is the java code:
import android.os.Bundle; import android.webkit.WebView; import com.phonegap.*; public class App extends DroidGap { WebView webView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); webView = new WebView(this); webView.addJavascriptInterface(new message(), "Show"); super.loadUrl("file:///android_asset/www/index.html"); } class message { String msg() { return "Hello World!!"; } } }
here is javascript:
<script type="text/javascript"> { alert("Start"); alert(Show.msg()); alert("End"); } </script>
He shows the first warning, but after that nothing can help?
source share