环境(Linux的/ Eclipse的开发对Xoom的平板电脑上运行蜂窝3.0.1)Android的错误:java.lang.IllegalStateException:尝试重新查询一个已经关闭的游标
在我的应用我使用的相机(startIntentForResult( )) 拍照。拍完照片后,我得到了onActivityResult()回调,并能够使用通过“拍照”意图传递的Uri加载Bitmap。在这一点上我的活动重新开始,我在尝试将图像加载到图片库的错误:
FATAL EXCEPTION: main
ERROR/AndroidRuntime(4148): java.lang.RuntimeException: Unable to resume activity {...}:
java.lang.IllegalStateException: trying to requery an already closed cursor
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2243)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1019)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:126)
at android.app.ActivityThread.main(ActivityThread.java:3997)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: trying to requery an already closed cursor
at android.app.Activity.performRestart(Activity.java:4337)
at android.app.Activity.performResume(Activity.java:4360)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2205)
... 10 more
我使用的唯一光标逻辑是图像拍摄后我转换的URI文件使用以下逻辑
String [] projection = {
MediaStore.Images.Media._ID,
MediaStore.Images.ImageColumns.ORIENTATION,
MediaStore.Images.Media.DATA
};
Cursor cursor = activity.managedQuery(
uri,
projection, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)
int fileColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
if (cursor.moveToFirst()) {
return new File(cursor.getString(fileColumnIndex));
}
return null;
任何想法我做错了什么?
你是专门针对蜂窝。刚刚发现,由于startManagingCursor(),我的Eclair +应用程序在Honeycomb中被破解。我的应用程序针对的是手机,但是当冰淇淋三明治出现时,并不期待愤怒的客户。 – Tenfour04 2011-05-13 22:05:47
是的,我专门针对蜂窝(片剂)。 – 2011-05-18 20:58:16
@ cyber-monk嗨 - 我有问题。我无法实现这个,因为我的代码无法识别CursorLoader。我正确导入它,但它不能识别导入。我该如何解决? – Mxyk 2012-03-02 13:51:05