Friday, April 20, 2012

Download image from server in Android



public class DownloadImage {
 public static Bitmap downloadImg()
 {
  URL url = null;
  Bitmap _bitmap = null;
  try
  {
   url = new URL("https://www.google.co.in/ig/images/weather/cloudy.gif");
   _bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
  }
  catch (MalformedURLException e)
  {
   e.printStackTrace();
  }
  catch (IOException e)
  {

   e.printStackTrace();
  }
  return _bitmap;
 }
}

No comments:

Post a Comment