WebView无法加载图片android

lon*_*gdw 0 android webview

<img src='http://lt.ltcx.net.cn:109/upload/image/XheditorProjData/2013/10/18/31c314e0-a76a-4a72-8f9e-991d73a44990.jpg' alt='' />
Run Code Online (Sandbox Code Playgroud)

我想用webview加载图片,这些是我的代码:

mWebView = (WebView) findViewById(R.id.webview);
    // ???????
    mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
    mWebView.getSettings().setLayoutAlgorithm(
            LayoutAlgorithm.SINGLE_COLUMN);
    mWebView.getSettings().setBlockNetworkImage(false);
     mWebView.getSettings().setJavaScriptEnabled(true);
     mWebView.loadDataWithBaseURL(null, url, "text/html",
                "UTF-8", null);
Run Code Online (Sandbox Code Playgroud)

但是图像无法显示.我使用HttpURLConnection读取二进制流来加载这个url,它可以工作.我不知道为什么我不能用webview加载图像.

小智 5

你在下面的logcat中得到了响应:

Mixed Content: The page at 'https://' was loaded over HTTPS, 
                 but requested an insecure image.

Webview cannot load the images with http request after 
                 android KITKAT, so we have to set the websetting.
Run Code Online (Sandbox Code Playgroud)

我粘贴下面的代码,希望你能解决问题.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            webview.getSettings().setMixedContentMode(
                        WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
 }
Run Code Online (Sandbox Code Playgroud)