public static void starter(){
File file = new File(path);
galleryIda = new ArrayList<Bitmap>();
String str = null;
int num = 0;
String[] flist = file.list();
if(flist != null)
Log.i("tag","파일갯수"+(flist.length));
int imgCount = flist.length;
if ( file.listFiles().length > 0 )
for ( File f : file.listFiles() ) {
str = f.getName(); // 파일 이름 얻어오기
//map[num] = BitmapFactory.decodeFile(path+str,options);
try {
if (!((path+str).matches(".*jpg.*")
||(path+str).matches(".*gif.*")
||(path+str).matches(".*png.*"))) continue;
Bitmap map = loadBitmap(context,path+str);
Log.i("tag","...path : " + (path+str));
galleryIda.add(map);
if (map != null && !map.isRecycled())
{
map.recycle();
map = null;
System.gc();
}
} catch (OutOfMemoryError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
num++;
}
Log.i("tag","done");
}
특정디렉터리에 있는 사진파일만 받아오는데 120M이상 받아오면 에러가 나더라구요 그래서 위와 같이
if (map != null && !map.isRecycled())
{
map.recycle();
map = null;
System.gc();
}
추가했습니다.
main activity 에서 위와 같은 소스 진행이 됩니다. 그리고 galleryIda에 있는 리스트를 adapterviewflipper에 붙이는 소스인데요 마지막에 done까지 확인되는데 이후에 activity가 나올때
07-25 14:56:56.319: E/AndroidRuntime(21270): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@42aa61d0
에러가 나옵니다.....
사진하나하나받아오는것은 loadBitmap에서 제어가 가능했는데... 재사용에러는 도무지 감이 안잡히네요 ㅠㅠ
혹시 비슷한 경험 있으시면 도움 부탁드립니다!!!