I have a layout which I'm adding ImageViews (about 13) to at run time using a single thread. When I load more than 7 or 8 images (970px x 970px, 270kb) the application crashes displaying an out of memory error. Now when I load the same image rather than choosing 13 different images it displays fine. And also when I reduce the size of the images (16px x 16px, 770bytes) it displays fine.
So does anyone know what the max memory allowed when loading images? What is the best way to get around this issue? Obviously people have come across this issue before and solved it due to loading image galleries etc.. what's the best way to load these images into the application? Any help would be greatly appreciated.
The following is how I'm reading the image from the resources. This is within a loop that I am taking the "drawableName" from a list of objects that I'm reading through. This is all within the onPostExecute of a thread (i.e. new AsyncTask())
String defType = "drawable";
String defPackage = this.getPackageName();
int resourceId = Activity.this.getResources().getIdentifier(drawableName, defType, defPackage);
((ImageView) view.findViewById(R.id.iv_image)).setImageResource(resourceId);