Monday, July 4, 2011

Andriod get image from Url

ImageView iv = new ImageView(context);

try{
String url1 = "http:///test/abc.jpg";
URL ulrn = new URL(url1);
HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
InputStream is = con.getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(is);
if (null != bmp)
iv.setImageBitmap(bmp);
else
System.out.println("The Bitmap is NULL");

}catch(Exception e){}
}

No comments:

Post a Comment