get Image From URL - Android Network

Android examples for Network:URL

Description

get Image From URL

Demo Code


//package com.java2s;

import java.io.InputStream;

import java.net.URL;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {
    public static Bitmap getImageFromURL(String strUrl) {
        Bitmap bmp = null;/*from   w  w w .  j  a  va 2s .c o  m*/
        try {
            URL url = new URL(strUrl);
            InputStream in = url.openStream();
            bmp = BitmapFactory.decodeStream(in);
            in.close();
        } catch (Exception e) {
            return null;
        } catch (Error err) {
            return null;
        }
        return bmp;
    }
}

Related Tutorials