Android根据URL获取Bitmap

为了方便记忆,写下。

 s为url

需要添加网络权限,还有开启子线程访问网络
public Bitmap getBitmap(String s)
{
Bitmap bitmap = null;
try
{
URL url = new URL(s);
bitmap = BitmapFactory.decodeStream(url.openStream());
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}

return bitmap;
}

}

posted on 2015-01-13 12:17  风者之心  阅读(2397)  评论(0编辑  收藏  举报

导航