Search code examples
androidimageandroid-imageviewandroid-imageimageurl

How to load one image in android WITH OUT download


know anyone of you how can I use one photo from URL with out download? Because I can have a lot of images and if my application CANT download all of them... I've found one function on web he how can do this but it don't work.

public static Drawable LoadImageFromWebOperations(String url) {
        try {
            InputStream is = (InputStream) new URL(url).getContent();
            Drawable d = Drawable.createFromStream(is, "src name");
            return d;
        } catch (Exception e) {
            return null;
        }
    }

I really need that, so have anyone any idea?


Solution

  • You can use Picasso lib for downloading image from url:

    http://square.github.io/picasso/

    Example:

    Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);