0

I would like to entirely disable the menu and back keys as soon as possible in the creation sequence of my activity.

Currently, I can only manage to disable the effect of the back button, the menu key still launches the Google search (I'm on a Samsung device FYI :))

Things I have tried: Overriding the following in my Activity:

@Override
public boolean onMenuOpened(int featureId, Menu menu)
{
    // TODO Auto-generated method stub
    return false;
}
@Override
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
{
    // TODO Auto-generated method stub
    return false;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    // TODO Auto-generated method stub
    return false;
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
    // TODO Auto-generated method stub
    return false;
}
@Override
public boolean onKeyShortcut(int keyCode, KeyEvent event)
{
    // TODO Auto-generated method stub
    return false;
}
@Override
public boolean onSearchRequested()
{
    // TODO Auto-generated method stub
    return false;
}
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event)
{
    // TODO Auto-generated method stub
    return false;
}

Also tried all this with "true" instead (was getting desperate). Also tried being more specific with my overrides and tried the typical (KeyEvent.KEYCODE_SEARCH, _DOWN, etc..) (since this is just a subset of the above, it was sure it wouldn't work... don't even know why I tried!)

Anyone have any ideas?

Thanks!

/e Removed part about vibration

Werner
  • 769
  • 2
  • 6
  • 19
  • AFAIK you cannot completely disable them to where they wont vibrate, you can only override what they do – tyczj Dec 18 '13 at 14:44
  • Hmm ok, well in that case I suppose I would just need a fix for the "search on long menu key press" issue. Thanks for info :) – Werner Dec 18 '13 at 14:45
  • 1
    Please search before you post a question. Just do a search for overriding the key you want to negate. For instance: android override back button. You will find many results such as: http://stackoverflow.com/questions/3141996/android-how-to-override-the-back-button-so-it-doesnt-finish-my-activity – lentz Dec 18 '13 at 15:07
  • Thanks for your concern with keeping the forums a cleaner place. That being said, had you read my entire question, you would notice the back button is currently working as I want it to (or well, not working :)) and that the issue now lies with stopping the Google search from being triggered when the menu button is longpressed. Also, if you look closely, the solution described in the accepted answer from the link you posted has already been tested (note the code I posted). But thanks for the comment anyways! – Werner Dec 18 '13 at 15:16
  • @Werner Were you able to disable menu button in Android Lollipop and Higher – Tejas Apr 21 '16 at 09:56

0 Answers0