我添加了suppresslint @SuppressLint({" SetJavaScriptEnabled"," JavascriptInterface"})以避免错误
但Android 4.2,4.3设备仍有空白区域
有人建议我解决这个问题。
web_content_url.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.i(TAG, "Processing webview url click...");
pbar2.setVisibility(view.VISIBLE);
view.loadUrl(s[1]);
return true;
}
public void onPageFinished(WebView view, String url) {
Log.i(TAG, "Finished loading URL: " + url);
pbar2.setVisibility(view.GONE);
view.loadUrl("javascript:MyApp.resize(document.body.getBoundingClientRect().height)");
super.onPageFinished(view, url);
}
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
Log.e(TAG, "Error: " + description);
pbar2.setVisibility(view.VISIBLE);
}
});
web_content_url.addJavascriptInterface(this, "MyApp");