当请求无效的URL时,Controller永远不会进入“onReceivedError”方法。但是在正确调用加载有效页面“onProgressChanged”时。
代码:
try {
webView = (WebView) findViewById(R.id.webViewEvents);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
System.out.println("on Progress Changes : ");
}
});
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
System.out.println("on Error received : ");
}
});
webView.loadUrl("http://google.com");
} catch (Exception e) {
System.out.println("Exception while loading: " + e);
}