您的位置:首页 > 理论基础 > 计算机网络

常用代码片段(一) - 加载网络图片

2011-03-08 09:01 232 查看

一、关键字

Image. URL, URLConnection, BitmapFactory

二、代码片段

public Bitmap getRemoteImage(final URL aURL) {

try {

final URLConnection conn = aURL.openConnection();

conn.connect();

final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());

final Bitmap bm = BitmapFactory.decodeStream(bis);

bis.close();

return bm;

} catch (IOException e) {

Log.d("DEBUGTAG", "Oh noooz an error...");

}

return null;

}
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  网络 null url
相关文章推荐