When you want to download a Image from the Web and Display it in Android in a ImageView i encountered two different approaches:
1. Download the Image and Display it:
Drawable DownloadDrawable(String url, String src_name) throws java.io.IOException { return Drawable.createFromStream(((java.io.InputStream) new java.net.URL(url).getContent()), src_name); } [...] try { Drawable drw = DownloadDrawable("http://www.google.de/intl/en_com/images/srpr/logo1w.png", "src") ImageView1.setImageDrawable(drw); } catch (IOException e) { // Something went wrong here } |