Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6951165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:11:05+00:00 2026-05-27T14:11:05+00:00

I’d like for my menu button in my main activity to be open at

  • 0

I’d like for my menu button in my main activity to be open at all times. I’ve used:

@Override
public void onAttachedToWindow() {
   super.onAttachedToWindow();
   openOptionsMenu();
}

which opens the menu when I go to the Activity. However, when I press the menu botton option to go to another activity and press the back button, the menu goes away and requires that I press the “menu” key to get it back. I’d like for the menu to stay open at all times for this particular activity.

I’ve tried to override the Activity’s onBackPressed:

@Override

public void onBackPressed(){
   super.onBackPressed();
   this.openOptionsMenu();
}

And I’ve tried adding this.openOptionsMenu in the onCreate. When I do that, my application crashes with the error:

12-17 09:19:46.674: ERROR/AndroidRuntime(4940): FATAL EXCEPTION: main
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cmu.community/com.cmu.community.HomeActivity}: android.view.WindowManager$BadTokenException: Unable to add window — token null is not valid; is your activity running?
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.os.Handler.dispatchMessage(Handler.java:99)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.os.Looper.loop(Looper.java:123)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at java.lang.reflect.Method.invoke(Method.java:521)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at dalvik.system.NativeStart.main(Native Method)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): Caused by: android.view.WindowManager$BadTokenException: Unable to add window — token null is not valid; is your activity running?
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.view.ViewRoot.setView(ViewRoot.java:505)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.view.Window$LocalWindowManager.addView(Window.java:424)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:463)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:378)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.app.Activity.openOptionsMenu(Activity.java:2330)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at com.cmu.community.HomeActivity.onCreate(HomeActivity.java:105)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-17 09:19:46.674: ERROR/AndroidRuntime(4940): … 11 more

Does anyone have a solution for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:11:06+00:00Added an answer on May 27, 2026 at 2:11 pm

    Options menu is for actions that you want to be hidden. Add buttons to your layout for the actions that you want to always be accessible.

    Options menu was really not designed for what you want it to do. Thus if you solve your current problem in some way, your QA (or users) will soon find other problems for you to solve.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.