BitmapFactory.decodeStream(is); 內存溢出,,這個問題咋解決啊
? ?URL fileUrl = null;
? ?Bitmap bitmap = null;
? ?InputStream is = null;
? ? Log.v("jsonpic","圖片地址"+ Strurl);
? ? ? ?try {
? ? fileUrl = new URL(Strurl);
? ? ? ?HttpURLConnection conn = (HttpURLConnection) fileUrl
? ? ? ? ? ? ? ?.openConnection();
? ? ? is =new BufferedInputStream( conn.getInputStream());
? ? ? ? ?
? ? ??
? ? ? bitmap = BitmapFactory.decodeStream(is);
? ? ? ?
? ? ? ?conn.disconnect();//釋放資源
? ? ?
? ?} catch (IOException e) {
? ? ? ?e.printStackTrace();
? ? ? ?Log.v("jsonpic", e.toString());
? ?}finally{
? ? ?is.close();
? ?}
? ?return bitmap;
2016-05-14
主要是你下載的圖片太大了,加載到內存造成了內存的溢出
android 提供的api文檔中Training>>Building Apps with Graphics & Animation>>
Loading Large Bitmaps Efficiently 提供了解決該問題的思路