Display image issue with loadDataWithBaseURL () in Android

In my application, I am displaying data in a webview, but it cannot display images in a webview.

I used loadDatawithBaseURL () method.

This is my code.

webview.loadDataWithBaseURL ("file: /// 059600656X /", data, "text / html", "UTF-8", "about: blank");

// data here is a string object containing gtml parsing data.

I think he cannot find images in the given directory.

Can anyone help me?

+2


a source to share


3 answers


You cannot use plain file:///

urls with loadDataWithBaseURL()

, and "about:blank"

probably is not a valid base url.



0


a source


To make loadDataWithBaseURL work, you need to make sure of two things:

All src images include "file: /// android_asset / imagename"

and the images are in the assets folder!



So, contrary to answer1, it's just as easy!

Munir Syed

0


a source


When you use LoadDataWithBaseURL you must specify the image resource as ur baseurl and the data must be ur array or image renderer.

Example

wv.loadDataWithBaseURL("file:///android_asset/", srray[position], "text/html", "UTF-8", null);

      

this should help me

0


a source







All Articles