martedì 27 settembre 2011

Android: Caricare un'immagine dal web


public Bitmap getRemoteImage(final URL aURL) {
      try {
            final URLConnection conn = aURL.openConnection();
            conn.connect();
            final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
            final Bitmap bm = BitmapFactory.decodeStream(bis);
            bis.close();
            return bm;
      } catch (IOException e) {
            [...]
      }
      return null;
}

Nessun commento: