Android WebView: large local image not uploaded / displayed

I am trying to display a large image (~> 1000x1000) in a WebView . The image is in the resource folder. The problem is that the image does not load, instead I see a small blue square with a question mark (presumably this means that the image cannot be loaded). I made a copy of the image and resized it to ~ 500x500. I upload both original and resized images, and the resized image is displayed well.

This is the code I'm using. largeimage.jpg is about 1500x1100, and smallimage.jpg is the same image whose size is about 500x300.

 public void loadImages() { final String mimeType = "text/html"; final String encoding = "utf-8"; final String html = "<img src=\"file:///android_asset/largeimage.jpg\" />" + "<img src=\"file:///android_asset/smallimage.jpg\" />"; // webView is defined elsewhere webView.loadDataWithBaseURL("fake://not/needed", html, mimeType, encoding, ""); } 

WebView has a small question mark with a blue square, followed by a loaded small image.

Why is this happening? Is there a restriction on WebView ? Is there a file size limit for Android? I'm new to Android, so maybe I missed a simple implied restriction. If the problem is a kind of limit, can someone tell me what the maximum allowable image size (in both resolution and file size) will be?

+4
source share

All Articles