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();

你可能感兴趣的:(android)