如下这段代码。每次只能进行到log处、请教这是什么原因?
for (int i = 0; i < arry.length(); i++) {
JSONObject js = arry.getJSONObject(i);
String path = js.getString("teamimg");
URL url = new URL("http://192.168.1.111:8080"+path);
Log.i("haha",url+"");
InputStream is = url.openStream();
bitmap = BitmapFactory.decodeStream(is);
}
URL url = new URL(sUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is, null, options);
如果图片太大,你还得考虑内存溢出的问题
想必楼主是新手。开发anddroid两年多,基本不会自己下载网络图片,直接用框架(android-universal-imageloader、fresco、afinal、xutils…)
如果势必要自己下载,建议 先直接下载到sd卡/内置储存,然后再读取(所谓的持久化缓存)。不然你每次加载图片都从网上load,用户要耗多少流量呀…