I use GridView to display thumbnails from MediaStore. If I launch and close my application 2-3 times it crashes with out of memory error. System.gc() is called in onCreate of main activity. If comment call setImageURI then no errors. Maybe I need to explicitly clear memory somehow? Please, help.
public View getView(int position, View convertView, ViewGroup parent){
ImageView i;
if (convertView == null) {
i = new ImageView(activity.getApplicationContext());
i.setLayoutParams(new GridView.LayoutParams(92, 92));
i.setScaleType(ImageView.ScaleType.CENTER_CROP);
} else {
i = (ImageView) convertView;
}
Uri imageUri = thumbUri(position);
i.setImageURI(imageUri); // <--- no error if this string is commented
return i;
}