简体   繁体   English

退出我的活动时为什么会崩溃?

[英]Why am I getting a crash when exiting my Activity?

I am experiencing a crash in my app when I quit (via the back button) out of my Activity. 当我从我的活动中退出(通过后退按钮)时,我的应用程序出现崩溃。 So far as I can tell this is happening in the Android codebase and not mine, but I'm not completely convinced of that. 据我所知,这是在Android代码库中发生而不是我的,但我并不完全相信。

Here's the stacktrace from adb: 这是来自adb的stacktrace:

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

Anyone have any ideas/recommendations? 任何人都有任何想法/建议?

Can't help much, as there's no code. 不能帮助太多,因为没有代码。 Still looking at 还是看着

Caused by: java.lang.NullPointerException at android.app.Activity.performStop(Activity.java:3575) 引起:android.app.Activity.performStop的java.lang.NullPointerException(Activity.java:3575)

I just checked Activity.java 我刚刚查看了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;
            }
        }

Are you sure all cursors are released properly? 你确定所有游标都正确发布了吗?

在这种情况下对内部情况的极好解释: http//www.jjoe64.com/2011/06/how-to-fix-activityperformstop.html

In your Activity before startManagingCursor() method is called , your Cursor is null. 在调用startManagingCursor()方法之前的Activity中,您的Cursor为null。 Dont let the Cursor be null. 不要让Cursor为null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试删除“活动”上的操作栏时,为什么会出现此异常? - Why am I getting this Exception when I try to remove Action Bar on my Activity? 从对话框调用活动方法时,为什么会出现 IndexOutOfBoundsException 错误? - Why am I getting an IndexOutOfBoundsException error when calling an activity method from my dialog? 尝试获取电话号码时,为什么我的活动崩溃了? - Why does my activity crash when I try to get a number? 我的活动中onResume()在Android中崩溃-为什么? - Getting crash in Android on onResume() in my activity - Why? 退出活动时Android 4.0上的线程崩溃 - Thread crash on Android 4.0 when exiting an Activity 为什么在运行应用程序时出现此错误? - Why am I getting this error when I run my app? 为什么在运行程序时出现NullPointerException? - Why am I getting a NullPointerException when I run my program? 为什么在加载 fxml 时会出现 stackoverflow? - Why am I getting a stackoverflow when loading my fxml? 为什么在尝试与我的服务器通信时出现此错误? - Why am i getting this error when trying to communicate with my server? 为什么在并行化我的树搜索时会得到这个 output? - Why am I getting this output when parallelising my tree search?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM