場景
使用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();
}
});