I'm trying to get an image from a Url into an ImageView. I've searched for it all day and I've tried lots of different solutions but none of them work for me...the image doesn't load. This is my code:
String imageUrl = "http://www.photo-flash-maker.com/img/file_formats/jpg_file.jpg";
iv.setImageDrawable(getImage(imageUrl));
//...
public static Drawable getImage(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src");
return d;
} catch (Exception e) {
return null;
}
}
I found it here: How to display image from URL on Android because this seems to be the simplest solution but the image doesn't load at all. Any solutions?