在我的应用程序中,我在 android 4.0 中遇到问题。在 ANDROID 2.3 上没有遇到此问题以下是导致问题的步骤 - 1. 我有一个主要活动 TaskManagerActivity(活动 1) 2. 然后我转到另一个活动 ReminderModificationActivity (活动 2) 3. 进行一些 DB 更改并返回到活动 1 4.然后按返回按钮退出应用程序。当我尝试再次打开应用程序时出现以下错误 -
11-06 13:25:37.075: E/AndroidRuntime(6591): FATAL EXCEPTION: main
11-06 13:25:37.075: E/AndroidRuntime(6591): java.lang.RuntimeException: Unable to resume activity {ray.kaushik.simple.task.manager/ray.kaushik.simple.task.manager.ReminderModificationActivity}: java.lang.IllegalStateException: trying to requery an already closed cursor android.database.sqlite.SQLiteCursor@412a9708
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2575)
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2603)
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.os.Handler.dispatchMessage(Handler.java:99)
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.os.Looper.loop(Looper.java:137)
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-06 13:25:37.075: E/AndroidRuntime(6591): at java.lang.reflect.Method.invokeNative(Native Method)
11-06 13:25:37.075: E/AndroidRuntime(6591): at java.lang.reflect.Method.invoke(Method.java:511)
11-06 13:25:37.075: E/AndroidRuntime(6591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-06 13:25:37.075: E/AndroidRuntime(6591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-06 13:25:37.075: E/AndroidRuntime(6591): at dalvik.system.NativeStart.main(Native Method)
11-06 13:25:37.075: E/AndroidRuntime(6591): Caused by: java.lang.IllegalStateException: trying to requery an already closed cursor android.database.sqlite.SQLiteCursor@412a9708
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.app.Activity.performRestart(Activity.java:5051)
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.app.Activity.performResume(Activity.java:5074)
11-06 13:25:37.075: E/AndroidRuntime(6591): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2565)
11-06 13:25:37.075: E/AndroidRuntime(6591): ... 10 more
我认为我的应用程序正在尝试加载我不想要的 Activity 2。
在活动 1 上按下 bac 按钮上的代码 -
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if(isBackPressed){
moveTaskToBack(true);
mDBHelper.close();
finish();
}else{
Toast.makeText(getApplicationContext(), "Please press back again to exit application", Toast.LENGTH_SHORT).show();
isBackPressed = true;
}
return true;
}
return super.onKeyDown(keyCode, event);
}
sumone plz可以帮帮我吗..?? 请详细说明,因为我是 android 开发的新手。谢谢