Android应用中WebView访问https SSL证书网页时,Google Play 总是报 WebView 的 onReceivedSslError 错误。为避免谷歌安全警告,要重写WebView的onReceivedSslError方法,此时要弹框提示用户,是否忽略SSL错误,继续访问网页。
@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();
}
若无弹框提示,出现了SSL错误,应用会被google以[违反了广告ID“ ("advertising ID")”政策]为由拒绝。
参考:
解决Google Play审核中的WebViewClient.onReceivedSslError问题
Google play WebViewClient.onReceivedSslError
来源:CSDN
作者:lyl0530
链接:https://blog.csdn.net/lyl0530/article/details/104048047