我使用此代码在Sdcard上加载缩略图,设备工作正常,但是设备使用ROM MIUI然后它有问题 “例外细节: java.lang.IllegalStateException:进程3188超出了游标配额100,将其杀死“
请帮我解决,谢谢。
public static Bitmap getThumbnailByPath(ContentResolver cr, String path)
throws Exception {
String[] projection = { MediaStore.Images.Media._ID };
Cursor cursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection, MediaStore.Images.Media.DATA + "=?",
new String[] { path }, null);
if (cursor != null && cursor.moveToFirst()) {
long id = cursor.getLong(0);
return getThumbnailById(cr, id);
} else
cursor.close();
return null;
}
public static Bitmap getThumbnailById(ContentResolver cr, long idPhoto)
throws Exception {
return MediaStore.Images.Thumbnails.getThumbnail(cr, idPhoto,
MediaStore.Images.Thumbnails.MINI_KIND, options);
}
答案 0 :(得分:11)
您必须始终关闭游标。
使用类似的东西:
Cursor cursor = ...;
try {
if (cursor.moveToFirst())
return getThumbnailById(cr, cursor.getLong(0));
else
return null;
} finally {
cursor.close();
}