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() {@Overridepublic void onClick(DialogInterface dialog, int which) {handler.proceed();}});builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {@Overridepublic 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
Android 上线Google play 总是报 WebView 的 onReceivedSslError 错误
Android WebView访问SSL证书网页(onReceivedSslError)