【发布时间】:2019-04-19 21:40:25
【问题描述】:
如何编写一个 html 文件,以便在特定的 android 应用程序运行 html 文件时它会运行 JavaScript? android 应用程序中有一个名为 examplefunction()
我期望的 html 看起来与此类似,但我无法正确处理。
<html>
<body>
<script>
document.write(javascript:Android.examplefunction())
</script>"
</body>
</html>
android 应用程序运行
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(this, "Android");
webView.loadUrl("www.example.com/test.html");
我正在读这样的html
public void onPageFinished(WebView webView, String str) {
webView.evaluateJavascript("(function(){return window.document.body.outerHTML})();", new ValueCallback<String>() {
public void onReceiveValue(String str) {
(code that uses the output of examplefunction())
}
});
}
【问题讨论】:
标签: android android-webview webviewclient