public class GetBitmapUtil { public Bitmap getBitmapByUrl(String url){ Bitmap bitmap = null; try { URL url2=new URL(url); HttpURLConnection httpURLConnection=(HttpURLConnection) url2.openConnection(); httpURLConnection.setReadTimeout(3000); int code=httpURLConnection.getResponseCode(); if(code==200){ bitmap=BitmapFactory.decodeStream(httpURLConnection.getInputStream()); } } catch (Exception e) { e.printStackTrace(); } return bitmap; } }
原文地址:http://blog.csdn.net/u014600432/article/details/42060093