Android之读取网络上图片

String uriPic = "http://lh3.ggpht.com/_s354WAuIc9E/" + "R_DpW4Rzj-I/AAAAAAAAAsc/Ox73tdxGLSw/logo.jpg";

/* new URL对象将网址传入 */ 

URL  imageUrl = new URL(uriPic);

/* 取得联机 */

HttpURLConnection conn = (HttpURLConnection) imageUrl .openConnection();

conn.connect();

/* 取得回传的InputStream */

InputStream is = conn.getInputStream();

/* 将InputStream变成Bitmap */

bitmap = BitmapFactory.decodeStream(is);

/* 关闭InputStream */

is.close();

posted on 2012-05-27 10:34  lee0oo0  阅读(254)  评论(0编辑  收藏  举报