当我从我的活动中退出(通过后退按钮)时,我的应用程序出现崩溃。据我所知,这是在Android代码库中发生的而不是我的,但我并不完全相信。
这是来自adb的堆栈跟踪:
AndroidRuntime E Uncaught handler: thread main exiting due to uncaught exception
AndroidRuntime E java.lang.RuntimeException: Unable to stop activity {MyApp/MyApp.MainActivity}: java.lang.NullPointerException
AndroidRuntime E at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3097)
AndroidRuntime E at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3159)
AndroidRuntime E at android.app.ActivityThread.access$2400(ActivityThread.java:112)
AndroidRuntime E at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
AndroidRuntime E at android.os.Handler.dispatchMessage(Handler.java:99)
AndroidRuntime E at android.os.Looper.loop(Looper.java:123)
AndroidRuntime E at android.app.ActivityThread.main(ActivityThread.java:3948)
AndroidRuntime E at java.lang.reflect.Method.invokeNative(Native Method)
AndroidRuntime E at java.lang.reflect.Method.invoke(Method.java:521)
AndroidRuntime E at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
AndroidRuntime E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
AndroidRuntime E at dalvik.system.NativeStart.main(Native Method)
AndroidRuntime E Caused by: java.lang.NullPointerException
AndroidRuntime E at android.app.Activity.performStop(Activity.java:3575)
AndroidRuntime E at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3092)
AndroidRuntime E ... 11 more
任何人都有任何想法/建议吗?
答案 0 :(得分:14)
不能帮助太多,因为没有代码。 还在看
引起:java.lang.NullPointerException at android.app.Activity.performStop(Activity.java:3575)
我刚检查了Activity.java
final int N = mManagedCursors.size();
for (int i=0; i<N; i++) {
ManagedCursor mc = mManagedCursors.get(i);
if (!mc.mReleased) {
mc.mCursor.deactivate(); // line 3575
mc.mReleased = true;
}
}
您确定所有游标都已正确发布吗?
答案 1 :(得分:4)
在这种情况下,对内部情况进行了很好的解释:http://www.jjoe64.com/2011/06/how-to-fix-activityperformstop.html
答案 2 :(得分:0)
在调用startManagingCursor()方法之前的Activity中,您的Cursor为null。不要让Cursor为null。