I'm trying to open the options menu at the end of my onCreate method with the Activity.openOptionsMenu method, but I'm getting an "android.view.WindowManager$BadTokenException" (partial stack trace below). I think this is because the options menu hasn't been created yet, and I verified that onCreateOptionsMenu doesn't get called until I press the MENU button.
Is there a way to get the options menu created? If not, can someone supply a snippet for programmatically firing a key press of the MENU button? As promised, here is the stack trace: 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): at android.view.ViewRoot.setView(ViewRoot.java:456) 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): at android.view.Window$LocalWindowManager.addView(Window.java:409) 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): at com.android.internal.policy.impl.PhoneWindow.openPanel (PhoneWindow.java:578) 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): at com.android.internal.policy.impl.PhoneWindow.openPanel (PhoneWindow.java:493) 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): at android.app.Activity.openOptionsMenu(Activity.java:2231) 11-05 21:50:27.250: ERROR/AndroidRuntime(1906): at mypkg.MyActivity.onCreate(MyActivity.java:76) ... -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

