im在Android Studio中构建Webview应用。它在API 27或更低版本中效果很好。但是当我将API更改为28时,显示了错误。
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
bar.setVisibility(view.GONE);
String javaScript = "javascript:(function() {
document.getElementById('google_image_div').remove();})()";
webView.loadUrl(javaScript);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap
favicon) {
super.onPageStarted(view, url, favicon);
String javaScript = "javascript:(function() {
document.getElementById('google_image_div').remove();})()";
bar.setVisibility(view.VISIBLE);
}
});
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
bar.setProgress(newProgress);
}
});
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().getCacheMode();
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setAllowContentAccess(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setMediaPlaybackRequiresUserGesture(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.loadUrl("http://url");
}
我已经尝试了堆栈溢出中的每个建议。但这些都不是成功。