:
public class MainActivity extends CordovaActivity{
JavaScriptInterface JSInterface;
private static final int PERMISSION_REQUEST_CODE_LOCATION = 1;
@SuppressLint("JavascriptInterface")
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
JSInterface = new JavaScriptInterface(this);
loadUrl("file:///android_asset/www/index.html");
WebView webView = (WebView)appView.getEngine().getView();
webView.addJavascriptInterface(JSInterface, "JSInterface");
}
public class JavaScriptInterface {
Context mContext;
/** Instantiate the interface and set the context */
JavaScriptInterface(Context c) {
mContext = c;
}
public void changeActivity(){startActivity(new Intent(mContext,ChildWebView.class));}
}
}
は、私のようなJavaスクリプトコードからchangeActivity()メソッドをトリガーする https://github.com/square/duktape-android
Duktape埋め込み可能なJavaScriptエンジンは、Android用にパッケージ。