今天是2015年8月8日,昨天晚上刚刚下了一场大雨,今天的天气是多么的美好啊,但是今天却在加班,而且是上班三个多月的,第一次周末加班,没办法啊,项目马上就要收尾了,还有一个BUG没解决,加班吧,努力工作!~
这是我之前在网上收缩到的一个小例子,记下来不知道什么时候会用上
public static Bitmap getHttpBitmap(String url) {
URL myFileUrl = null;
Bitmap bitmap = null;
try {
Log.d("tag", url);
myFileUrl = new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();
conn.setConnectTimeout(0);
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is);
is.close();
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}