How to completly disable menu button on android?

11,393

Solution 1

You must return true for the menu to be displayed; if you return false it will not be shown. So I'm guessing this will work:

@Override
 public boolean onPrepareOptionsMenu (Menu menu) {
     .... .....
     return false;
 }

Solution 2

You must return false.

@Override
public boolean onMenuOpened(final int featureId, final Menu menu) {
    super.onMenuOpened(featureId, menu);
    return false;
}
Share:
11,393
Adam Varhegyi
Author by

Adam Varhegyi

I like the color blue. Often eating gyros.

Updated on June 08, 2022

Comments

  • Adam Varhegyi
    Adam Varhegyi almost 2 years

    For some reason if i long press my menu button while my app is loading content, it is just stops just like i pressed back key.

    I dont want the menu button to behave like this so my question is:

    How can i completly disable menu button ? I dont ever need it in my app i just want to turn it off.

    i tried:

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event){
    
         if (keyCode == KeyEvent.KEYCODE_BACK){
            onBackPressed();
         }
    
    
        if (keyCode == KeyEvent.KEYCODE_MENU){
            return true;
        } 
        else{
            return super.onKeyDown(keyCode, event); 
        }
    
    }
    

    Menu button still working...

    Any help will be appreciated! Thanks.