Android Bitmap Create GetUrlDrawable(String url)

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

Description

Get Url Drawable

Declaration

public static Drawable GetUrlDrawable(String url) 

Method Source Code

//package com.java2s;

import java.io.InputStream;

import java.net.URL;
import java.net.URLConnection;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;

public class Main {
    public static Drawable GetUrlDrawable(String url) {
        try {//ww w  . ja  va  2s  .  c o m
            URL aryURI = new URL(url);
            URLConnection conn = aryURI.openConnection();
            InputStream is = conn.getInputStream();
            Bitmap bmp = BitmapFactory.decodeStream(is);
            return new BitmapDrawable(bmp);
        } catch (Exception e) {
            Log.e("ERROR", "urlImage2Drawable????????????imageUrl??"
                    + url, e);
            return null;
        }
    }
}

Related

  1. create2DBitmap(Bitmap bitmap)
  2. decodeFromBytes(byte[] bs, int reqWidth, int reqHeight)
  3. decodeFromResource(Resources res, int resId)
  4. decodeFromResource(Resources res, int resId, int reqWidth, int reqHeight)