Quantcast
Channel: Developer Feed - Snippet
Viewing all articles
Browse latest Browse all 178

How to load an remote image as a Drawable in Android?

$
0
0

Loading an remote image from a online server accessible via a URL as Drawable is very straightforward.

// Utililty Method

public static Drawable loadImageAsDrawable(String url) {
    try {

        // open the stream
        InputStream is = (InputStream) new URL(url).getContent();

        String imageName = "xyz";
        Drawable draw = Drawable.createFromStream(is, imageName );
        return draw;
    } catch (Exception e) {
      // something went wrong

       return null;
    }

read more


Viewing all articles
Browse latest Browse all 178

Trending Articles