Android 上线Google play 总是报 WebView 的 onReceivedSslError 错误

onReceivedSslError 是WebView的一个方法

解决办法,直接把下面代码粘贴到你的项目中就可以了。

//下面的方法解决Android6.0加载不出webView的问题
@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {

    final AlertDialog.Builder builder = new AlertDialog.Builder(WechatLoginActivity.this);
    builder.setMessage(R.string.notification_error_ssl_cert_invalid);
    builder.setPositiveButton("continue", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handler.proceed();
        }
    });
    builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handler.cancel();
        }
    });
    final AlertDialog dialog = builder.create();
    dialog.show();

}
发布了154 篇原创文章 · 获赞 36 · 访问量 22万+

猜你喜欢

转载自blog.csdn.net/yijiaodingqiankun/article/details/83021582