/**
* Webview在安卓5.0之前默認允許其加載混合網絡協議內容
* 在安卓5.0之后,默認不允許加載http與https混合內容,需要設置webview允許其加載混合網絡協議內容
*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setting.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
同時,在
WebViewClient
@Override
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
super.onReceivedHttpError(view, request, errorResponse);
CustomProgressDialogUtils.dismissProgressDialog();
LogUtils.d("出錯了","22222");
//loadingFailed();
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
// 注意:super句話一定要刪除,或者注釋掉,否則又走handler.cancel() 默認的不支持https的了。
// super.onReceivedSslError(view, handler, error);
handler.proceed();// 接受所有網站的證書
}