Android - 带弹出窗口的NullPointerException

时间:2012-05-17 14:17:42

标签: java android android-widget

我的应用程序中有一个弹出窗口,一旦我在测试时得到以下NullPointerException。但是我的代码在堆栈跟踪中没有任何地方。

/dalvikvm(15212): threadid=1: thread exiting with uncaught exception (group=0x409f71f8)
E/AndroidRuntime(15212): FATAL EXCEPTION: main
E/AndroidRuntime(15212): java.lang.NullPointerException
E/AndroidRuntime(15212):    at android.view.View.onDetachedFromWindow(View.java:9709)
E/AndroidRuntime(15212):    at android.widget.TextView.onDetachedFromWindow(TextView.java:4492)
E/AndroidRuntime(15212):    at android.view.View.dispatchDetachedFromWindow(View.java:9818)
E/AndroidRuntime(15212):    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2266)
E/AndroidRuntime(15212):    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2266)
E/AndroidRuntime(15212):    at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2248)
E/AndroidRuntime(15212):    at android.view.ViewRootImpl.doDie(ViewRootImpl.java:3707)
E/AndroidRuntime(15212):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2584)
E/AndroidRuntime(15212):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(15212):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(15212):    at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime(15212):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(15212):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(15212):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(15212):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(15212):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 1195):   Force finishing activity com.android.contacts/.activities.PeopleActivity

任何人都可以帮我找到根本原因吗?

1 个答案:

答案 0 :(得分:0)

您可能在弹出窗口显示之前,即在它连接到窗口之前调用finish()。交叉检查您为PeopleActivity调用finish()的位置。