calling javascript function from an android activity

后端 未结 7 1828
心在旅途
心在旅途 2021-01-06 01:13

I wan to call a javascript function from an android activity but it doesn\'t seem to work. I have used the android webview function webview.loadUrl(\"javascript:function()\"

7条回答
  •  长情又很酷
    2021-01-06 01:45

    Try it:

    String URL = "file:///android_asset/filename.html";
    webviewBrowser=(WebView)findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.setWebViewClient(new WebViewClient(webview.loadUrl(URL));
    

提交回复
热议问题