WebView加载不出来,显示空白页面

现象描述:webview加载H5链接是https,而h5中是图片地址拼接,造成加载不出来,显示空白页面。
log日志:
chromium: [INFO:CONSOLE(0)] "Mixed Content: The page at 'https://iot.onehaier.com/v2/cms/advert.detail.h5?advertId=201612141722070002' was loaded over HTTPS, but requested an insecure image 'http://onehaiercms.oss-cn-qingdao.aliyuncs.com/2016/12/14/17-21-340871526087485.jpg'. This request has been blocked; the content must be served over HTTPS., source: https://iot.onehaier.com/v2/cms/advert.detail.h5?advertId=201612141722070002 (0)

原因:H5链接是:https,而里边图片地址是:http;
Android webview 从Lollipop(5.0)开始webview默认不允许混合模式,https当中不能加载http资源,需要设置开启。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}

你可能感兴趣的:(WebView加载不出来,显示空白页面)