一般用Cursor后, 就立即close()了,但是在用managedQuery的时候, 却不能主动调用close()方法, 否则在Android 4.0+的系统上, 会发生崩溃
google的文档是这么写的
Warning: Do not call close() on a cursor obtained using this method, because the activity will do that for you at the appropriate time. However, if you call stopManagingCursor(Cursor) on a cursor from a managed query, the system will not automatically close the cursor and, in that case, you must call close().
也有人说用下面的方法可以避免这个问题
这个问题其实很简单 估计大家在查询数据库的时候用的是这个函数
viedoCursor = context.managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoColumns,null, null, null);
只要换成这样就可以了:
ContentResolver cr = context.getContentResolver();
viedoCursor = cr.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoColumns,null, null, null);
我也是无意间发现有着两种写法的 然后试了一下问题就解决了
参考:http://*.com/questions/9696868/unable-to-resume-activity-error