场景
使用WebView加载某一网址时,不能正常显示网页,在Logcat出现以下错误提示。
I/X509Util: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
解决方案
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
//千万不能调用super的方法,super方法中默认取消了处理
//super.onReceivedSslError(view, handler, error);
handler.proceed();
}
});