2015-05-17

[Android] 由圖片網址解圖為Bitmap. Decode an Image to Bitmap by its URL on internet


This is how to decode an image to Bitmap by its URL on internet.


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

String mImgUrl = "http://url.to.your.image.on.internet";
Bitmap bm = BitmapFactory.decodeStream((InputStream) new URL(mImgUrl).getContent());