You could simply post (to a View or a Handler) a Runnable from onCreate() to do this. You can also try to do it from onStart().
Activity.onWindowFocusChanged() is definitely NOT the right place. On Sun, Feb 21, 2010 at 5:00 PM, Chopcsu <st...@kilsby.com.au> wrote: > I am trying to make a PopupWindow show straight away when an activity > has started. > > when calling > public void showAtLocation (View parent, int gravity, int x, int y) > > I get the exception > ERROR/AndroidRuntime(2500): Caused by: android.view.WindowManager > $BadTokenException: Unable to add window -- token null is not valid; > is your activity running? > > At the moment I am calling from onCreate, but when calling from > onStart or onResume it still gives the same error. > > The activity api says the activity is supposed to be running after > onResume is called. Where is the best place to load up the PopupWindow > if it needs to be done straight away? > > > At the moment It looks like Activity.onWindowFocusChanged() is the > best place. > > -- > 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 > -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- 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