0

I am just about to learn myself how to create an android app. Right now I am looking for a way to use the menu hardware button. I read that I have to create a xml file, but i don't understand where I have to save that to? And what is the code for grab the menu button? Can anyone show me a simple example?

Brigitte Fellner
  • 245
  • 2
  • 4
  • 14

1 Answers1

0

There are lots of examples on this website, you can create a function on your activity to catch the event:

public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (event.getAction() == KeyEvent.ACTION_UP)
        {
            //your code
            return true;
        }
    }
    return super.onKeyUp(keyCode, event);
}
Yoann Hercouet
  • 17,894
  • 5
  • 58
  • 85