1. 程式人生 > >Android webview 載入https:// 網站時不展示 圖片資源

Android webview 載入https:// 網站時不展示 圖片資源

可能原因是:該圖片資源不是https的;

解決辦法:


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

原因:

Android webview 從Lollipop開始webview預設不允許混合模式,https當中不能載入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);