When Android loads a web page, some pictures cannot be loaded, but some pictures can be loaded.

I don’t know if you have ever encountered that when loading a web page, some pictures cannot be displayed, but some can. Why is this?

This is because webview loads https web pages. On Android 5.0 and above, if the image content is http, it cannot be loaded.

webview Starting from Lollipop (5.0), webview does not allow mixed mode by default. HTTP resources cannot be loaded in https. If you want to load them, you need to set them up separately. So you
need to add the following sentence


// 允许从任何来源加载内容,即使起源是不安全的;
       if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
    
    

           settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);

       }

おすすめ

転載: blog.csdn.net/qq_42221857/article/details/103298469