appView.addJavascriptInterface() does not work on API 17

前端 未结 4 2037
我寻月下人不归
我寻月下人不归 2021-02-01 05:27

i am able to use java function from my phonegap java script function and android 2.2 but same code is not run on API 17. what should i have to do to call native java code on fr

4条回答
  •  有刺的猬
    2021-02-01 06:22

    I just wrote the web application with addJavascriptInterface with API 17, it works well. I don't know what happened to your code. Maybe you can try these:

    make sure you add the :

    WebSettings webSettings = appView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    

    Second, why do you use super.loadUrl, not appView to load the html?

    objCustomNativeAccess = new CustomNativeAccess(this, appView);
    appView.addJavascriptInterface(objCustomNativeAccess, "CustomNativeAccess");
    appView.loadUrl("file:///android_asset/www/index.html");
    

提交回复
热议问题