简体   繁体   中英

Android - NullPointerException with popup window

I have a pop up window in my application and once I got the following NullPointerException while testing. But my code is nowhere in the stack trace.

/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

Can anyone help me find the root cause?

You might be calling finish() before your pop window is displayed ie before it gets attached to your window. Cross check where you are calling finish() for your PeopleActivity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM