download Image from Uri - Android Graphics

Android examples for Graphics:Image Download

Description

download Image from Uri

Demo Code


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import java.io.IOException;
import java.io.InputStream;

public class Main{
    public static Bitmap downloadImg(String uri) {
        InputStream is = null;/*www  .  j a  v  a2 s.co  m*/
        try {
            is = HttpHandler.httpGetStream(uri, null);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (is == null) {
            return null;
        }
        return BitmapFactory.decodeStream(is);
    }
}

Related Tutorials