Sunday 1 November 2020

WebView not loading images nor css on some Android devices

I load html files on webview along with css applied using the following code:

@Override
protected void onCreate(Bundle savedInstanceState) {
     testWV = (WebView) findViewById(R.id.mywebview1);

     testWV.setDelegate(this);
     testWV.setApplicationLanguage(((iKitabApp) getApplication()).getLanguage());

     testWV.setVerticalScrollBarEnabled(false);
     testWV.setHorizontalScrollBarEnabled(false);
     testWV.getSettings().setSupportZoom(true);
     testWV.getSettings().setBuiltInZoomControls(true);
     testWV.getSettings().setDisplayZoomControls(false);

     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
         testWV.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
        );
     }
     testWV.getSettings().setJavaScriptEnabled(true);

}


new Thread(new Runnable() {
        @Override
        public void run() {
             testWV.post(new Runnable() {
                @Override
                public void run() {
                    
                    testWV.loadDataWithBaseURL(filePath,  htmlContent, "text/html", "UTF-8", "about:blank");
                }
            });
        }
});

Recently on some android devices as Galaxy 6 and note 10, the WebView is no longer loading the images in the WebView nor applying the css file which comes with it. While it's still loading the whole content correctly on other android devices.

Kindly find below the result of the same html file on 2 different android devices

enter image description here enter image description here

Would you kindly advise on the matter.



from WebView not loading images nor css on some Android devices

No comments:

Post a Comment