본문 바로가기

Android

내장 갤러리 이미지 불러올때 OutOfMemory 문제!

흠 비트맵을 쓰면 항상 아웃오브메모으리!!!

예전에 AndroidManifest파일에 LargeHeap=true 라는 해결책이 있었으나 이번 프로젝트는

프로요를 지원해야한단다 .... 

역시나 비트맵을 쓰면서 아웃오브메모으리...!!

내장 갤러리에서 사이즈가 큰 이미지를 불러왔더니 !!!!!!!!!!!!!!!!!!!


================================================================

AssetFileDescriptor afd = ctx.getContentResolver().openAssetFileDescriptor(uri, "r");

BitmapFactory.Options opt = new BitmapFactory.Options(); 

opt.inSampleSize = 4;

bitmap = BitmapFactory.decodeFileDescriptor(afd.getFileDescriptor(), null, opt);

================================================================


이런식으로 AssetFileDescriptor를 이용해서 비트맵을 그리면 된다고 했다 

우선 적용해봤으나 아웃오브메모리가 가끔씩 났기 때문에 좀더 지켜봐야겠다 

아 졸려 ㅠ