user 1234
user 1234

Reputation: 113

Android Images from web

I am developing a hybrid application in android. I am trying to load external images from web. but its not loading. Internal images were working fine, when I stored it in assests->www folder.The following code I am using to load external images from web

<img src="http:....gif" />

Help will be appreciated. Thanks in advance.

Upvotes: 0

Views: 156

Answers (1)

MKJParekh
MKJParekh

Reputation: 34301

I have been able to show the Image from net,

Java Code in MainActivity

    myWebView = new WebView(this);
    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.getSettings().setAppCacheEnabled(true);
    // myWebView.getSettings().setAppCachePath("/mnt/sdcard/mayur/");
    myWebView.getSettings().setLoadsImagesAutomatically(true);
    myWebView.getSettings().setCacheMode(
            WebSettings.LOAD_CACHE_ELSE_NETWORK);
    myWebView.loadUrl("file:///android_asset/chapters.html");

HTML file chapters.html in Assets folder

<html>
<body>
<img src="http://jimpunk.net/Loading/wp-content/uploads/loading1.gif" />
</body>
</html>

Upvotes: 1

Related Questions