在android里面加入webview的时候,有时候需要捕获http error,例如404等错误。在api 22 以下 系统提供onReceivedError方法。根据google官网提供的文档,onReceivedError可以捕获http Error。但是使用这个方法的时候,并没有捕获到404错误。
WebView webView = new WebView(this);
webView.setWebViewClient(new WebViewClient(){
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
}
});
webView.loadUrl("你加载的网址");
仔细查下了一下最新文档,原来google以前的文档存在bug,这里是google开发人员说的
**The docs a