我正在一个应用程序中工作,该应用程序具有用于在 webview 中加载的 url,在 andorid api 级别 13 之前,一切都可以正常工作,但是对于 andorid ics,它的行为不同,一些 url 正确加载,但有些在加载时会导致屏幕闪烁,我没有 url https 这些是简单的 http url。我不明白为什么会这样,请帮助我。我的代码是-
progressDialog = ProgressDialog.show(WebViewActivity.this, "",
"Loading...");
progressDialog.setCancelable(true);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClientICS());
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
PluginState state = WebSettings.PluginState.ON;
webview.getSettings().setPluginState(state);
webview.getSettings().setDomStorageEnabled(true);
webview.setBackgroundColor(0);
webview.getSettings().setSupportZoom(true);
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
if (view.getProgress() == 100) {
progressDialog.dismiss();
}
}
webview.loadUrl(url);
}
private class MyWebViewClientICS extends WebViewClient {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
Log.d("onReceivedError", errorCode + "" + description
+ "failingUrl" + failingUrl);
Toast.makeText(WebViewActivity.this,
"Sorry, error in loading page, please try again",
Toast.LENGTH_SHORT).show();
finish();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
}
提前致谢