Wednesday, September 21, 2011

Android: Hardware Menu button click event

The easiest way is to capture the onKeyDown event for the menu button click:



@Override
public boolean onKeyDown(int keycode, KeyEvent event ) {
 if(keycode == KeyEvent.KEYCODE_MENU)
{
  AlertDialog.Builder dialogBuilder
  = new AlertDialog.Builder(this)
  .setMessage("Test")
  .setTitle("Menu dialog");
  dialogBuilder.create().show();
 }
 return super.onKeyDown(keycode,event); 
}

No comments:

Post a Comment