Drawable.createFromStream and URL connection : Drawable « 2D Graphics « Android

Drawable.createFromStream and URL connection

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.drawable.Drawable;

public class NetworkUtil {

  public static Drawable getDrawableFromUrl(String url, String src_name) {
    try {
      return Drawable.createFromStream(
          ((InputStream) new URL(url).getContent()), src_name);
    } catch (MalformedURLException e) {
      return null;
    } catch (IOException e) {
      return null;


Related examples in the same category

1.Animate Drawables
2.ShapeDrawable Demo
3.Using GradientDrawable
4.Gets the image drawable from the url
6.Drawable Manager
7.get Drawable From Url
8.simply resizes a given drawable resource to the given width and height
9.Drawable Manager with Thread
10.get Drawable From Web Operation
11.Center a Drawable
12.Rotate around Center Point