load Image From URL - Android Graphics

Android examples for Graphics:Image Download

Description

load Image From URL

Demo Code


//package com.java2s;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import android.graphics.drawable.Drawable;

public class Main {
    public static Drawable loadImageFromURL(String url) {
        Drawable drawable = null;/*  w  w  w . j ava2 s .  c  om*/
        try {
            InputStream is = (InputStream) new URL(url).getContent();
            drawable = Drawable.createFromStream(is, "srcname");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return drawable;
    }
}

Related Tutorials