1

hi there i have got a sample code from Developer.android.com and it fetches image from webpage with specified url and for thumbnail also it fetches url from the same page, here is the sample code.

public class Images {
public final static String[] imageUrls = new String[] {
           "https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg",
"https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s1024/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg", };

public final static String[] imageThumbUrls = new String[] {
        "https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s160-c/A%252520Photographer.jpg",
"https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s160-c/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg", };

here they use url to fetch the image from a webpage and dislpaying instead i have to show image from sdcard.

thank you can i edit the code for sdcard images.

Gopi.cs
  • 985
  • 1
  • 16
  • 41

1 Answers1

1

You able to show image from sdcard to webview .

Here is code sample.

mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
String imagePath = "file://"+ base + "/test.jpg";
String html = "<html><head></head><body><img src=\""+ imagePath + "\"></body></html>";
mWebView.loadDataWithBaseURL("", html, "text/html","utf-8", "");  

you need to append the"prefix "file://" before any file so as to display in the webview.

Md Abdul Gafur
  • 6,213
  • 2
  • 27
  • 37
  • Hi @Md Abdul it dont need it from a webview no need of html response just i have to show thumbnail of images from sdcard without accesing gallery thumbnail. – Gopi.cs Apr 10 '13 at 07:10
  • you want to show image thumbnail , like android default photo Gallery. – Md Abdul Gafur Apr 10 '13 at 07:14
  • yes but not from the default gallery thumbnail of android i have to create my own thumbnail folder, and i created it while processing it the thumbnail loads too slow is there any code to make it load fast. – Gopi.cs Apr 10 '13 at 07:21
  • https://github.com/nostra13/Android-Universal-Image-Loader . it load image in background. – Md Abdul Gafur Apr 10 '13 at 09:09