Right now when you hold down the menu button on my android device it pulls up a soft keyboard.Is there a way to override this? I would rather choose what happens on a long touch of this button.
When using onKeyLongPress it only detects when the “Back” button is held down. How can I make this work for the menu button?
For this, you can use the
onKeyLongPress()-method, offered by theKeyEvent.Callback-class (can be used in Activity’s too, since they are a subclass of theKeyEvent.Callback-class).There is also a little trick to make this work: You’ll have to tell Android to track a long-press click on the “Menu”-button as the
onKeyLongPress()-method will not be triggered otherwise. This is done in the normalonKeyDown()-method.So your code might look like this:
A great article with further informations can be found on the Android Developer Blog.