我们经常会见到html5和安卓混合开发,有时为了安全,采用https方式访问web端,这时候有部分手机会无法加载图片,扒开网页源码,图片是http的,把图片链接拿出来也是正常打开的,后台并没有问题 。
经过一番搜索 看官方给出的说明 Mixed content using HTTP and HTTPS on WebViews are disabled by default starting Lollipop. Is possible that is not working on devices with Lollipop? If this is the case, you can change the default WebView setting on Lollipop using: webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
Documentation here: http://developer.android.com/reference/android/webkit/WebSettings.html#setMixedContentMode(int)
Android webview 从Lollipop开始webview默认不允许混合模式,https当中不能加载http资源,需要设置开启。
1.把图片改成https的
2.
if (Build.VERSION.SDK_INT >= 21) {
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}