user1144251 user1144251 - 1 year ago 131
Android Question

Android soft menu key listener exists?

I have an issue where if I disable hardware menu buttons (ie back, home, menu). I'm left with a software menu bar on screen. But my previous key down listener for KEYCODE_MENU no longer works on this virtual menu button. Can someone help me with the right key listener for this virtual menu button?

Before the following works on hardware menu button but stops working when I disable hardware buttons and have soft menu button enabled in android:

public boolean onKeyDown(int keycode, KeyEvent e) {
switch(keycode) {
case KeyEvent.KEYCODE_MENU:
return true;
return super.onKeyDown(keycode, e);

Answer Source

New versions of Android do not have Menu button at all, although some manufacturers ahem Samsung keep adding hardware Menu button.

To have Menu button in the navigation bar, that will send Menu keycode, you will have to set targetSdkVersion to 10 in your AndroidManifest.xml, which will make your application look ancient.

You can realistically expect only three hardware buttons (e.g. buttons that will send keycodes) - Back, Volume Up, and Volume Down, and it's bad style to use Volume buttons for anything other than changing sound volume.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download