android - set url image to image view -


possible duplicate:
is possible use bitmapfactory.decodefile method decode image http location?

i have problem in set url image image view. tried below methods

method 1:

bitmap bimage=  getbitmapfromurl(bannerpath); image.setimagebitmap(bimage);   public static bitmap getbitmapfromurl(string src) {         try {             log.e("src",src);             url url = new url(src);             httpurlconnection connection = (httpurlconnection) url.openconnection();             connection.setdoinput(true);             connection.connect();             inputstream input = connection.getinputstream();             bitmap mybitmap = bitmapfactory.decodestream(input);             log.e("bitmap","returned");             return mybitmap;         } catch (ioexception e) {             e.printstacktrace();             log.e("exception",e.getmessage());             return null;         }     } 

method 2:

    drawable drawable = loadimagefromweboperations(bannerpath);     image.setimagedrawable(drawable);       private drawable loadimagefromweboperations(string url)     {          try          {              inputstream = (inputstream) new url(url).getcontent();              drawable d = drawable.createfromstream(is, "src name");              return d;          }catch (exception e) {              system.out.println("exc="+e);              return null;          }      } 

i tried above 2 methods not working . both showing debug/skia(266): --- decoder->decode returned false . used demo url image paths working. path not working .so please tell me wrong ,

thank in advance.

best regards.

just tested "method 1" in app , works fine.

you might have forgotten line in androidmanifest.xml file:

<uses-permission android:name="android.permission.internet" /> 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -