前段时间公司 app 的网页要走 https , 结果发现有的手机上图片不显示, 只显示了位置,花费了一些时间,最后在 stackoverflow 上找到了解决方案 . 在这里记录下.
Android webview 从Lollipop开始webview默认不允许混合模式,https当中不能加载http资源,因此需要设置开启.
参考链接 : http://stackoverflow.com/questions/31509277/webview-images-are-not-showing-with-https
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}