Android Drawable Create loadImageFromUrl(String url)

Here you can find the source of loadImageFromUrl(String url)

Description

load Image From Url

Declaration

public static Drawable loadImageFromUrl(String url) 

Method Source Code

//package com.java2s;

import java.io.IOException;
import java.io.InputStream;

import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.drawable.Drawable;

public class Main {
    public static Drawable loadImageFromUrl(String url) {
        URL m;/*from   w w w .j a v  a  2  s.  com*/
        InputStream i = null;
        try {
            m = new URL(url);
            i = (InputStream) m.getContent();
        } catch (MalformedURLException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Drawable d = Drawable.createFromStream(i, "src");
        return d;
    }
}

Related

  1. getPressedDrawable(int color)
  2. getDrawableByName(Context ctx, String name)
  3. getDrawable(final Context context, final String packageName, final int resourceID)
  4. drawableToTransitionDrawable( Drawable drawable)
  5. createTempImageFile(Context context, Drawable drawable)