在android WebView错误处理无法正常工作

时间:2013-02-26 14:44:47

标签: android android-webview

当请求无效的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);
    }

0 个答案:

没有答案