Hi, I am getting WindowManager$BadTokenException when i am trying to launch a popup window after inflating it from a xml layout. The key is if i wait for around 2 sec before launching the popup, it works fine, but when i try to open it immediately it crashes. Does anybody have any clue about this ?
Following is the code snippet causing the excepion : mInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mOptionsPanel = (ViewGroup)mInflater.inflate(R.layout.options, null); mOptionsPopup = new PopupWindow(mOptionsPanel,width,height); mOptionsPopup.showAtLocation(parent, gravity, x, y); Logs : 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.view.ViewRoot.setView(ViewRoot.java:476) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:180) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.view.Window$LocalWindowManager.addView(Window.java:435) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.widget.PopupWindow.invokePopup(PopupWindow.java:822) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.widget.PopupWindow.showAtLocation(PopupWindow.java:689) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at com.google.endpoint.pictureframe.PictureFrameSettings.showPopup(PictureFrameSettings.java:226) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at com.google.endpoint.pictureframe.PictureFrame$2.run(PictureFrame.java:269) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.os.Handler.handleCallback(Handler.java:587) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.os.Handler.dispatchMessage(Handler.java:92) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.os.Looper.loop(Looper.java:123) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at android.app.ActivityThread.main(ActivityThread.java:4363) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at java.lang.reflect.Method.invokeNative(Native Method) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at java.lang.reflect.Method.invoke(Method.java:521) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622) 05-04 07:57:54.060: ERROR/AndroidRuntime(1159): at dalvik.system.NativeStart.main(Native Method) Thanks, Vivek -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en