The MENU Key Is Dead. Again.

A quick bit of history for those of you relatively new to Android development: all Android 1.x and 2.x devices had a MENU key, used to bring up the options menu. With Android 3.0 and the advent of the system/navigation bar, device manufacturers no longer needed keys for HOME, BACK, and MENU. And, the action bar incorporated a “…” affordance for accessing the overflow, for items that would have been in the options menu and were not promoted to be toolbar buttons in the action bar itself.

(BTW: “affordance” is UI-speak for “thingy”)

Confusion began when we started having devices that had a MENU key and Android 3.0+. A few Android 2.x devices were upgraded to Android 4.0, and hundreds of developers of millions of Android devices, from manufacturers like Samsung and HTC, shipped with Android 4.x and a MENU key.

To accommodate this, the device would report whether it had a “permanent menu key”, and the action bar would choose whether to show the “…” affordance based upon the existence of this key. Devices with a MENU key would not get the “…”, but instead would use the MENU key to display the overflow.

This irritated many developers, for much the same reason as why the MENU key irritated those developers back in Android 1.x/2.x: the existence of a menu was not very discoverable. Many users would eventually realize that tapping the MENU key might uncover useful stuff, but not all users would make this connection. However, now developers could see an obvious alternative, in the form of the “…” affordance, and so they sought ways to trick the action bar into showing the “…” even on devices that had a MENU key.

And that was how the world worked… up until Android 4.4.

An unannounced change in Android 4.4 is that the “…” affordance should now always be shown in the action bar. The MENU key, if it exists, will still work, showing the overflow. Ideally, it shows the overflow as dropping down from the “…”, though that is not required. And the Compatibility Definition Document for Android 4.4 more forcefully suggests that the MENU key is obsolete.

Personally, I had not noticed this behavior, as none of the Nexus devices have a MENU key and I have been minimizing my use of the Android 4.4 emulator, as it is presently ARM-only. Hence, I had not been testing in MENU-key-equipped Android 4.4 environments, and so I missed this change. I am deeply indebted to whoever chimed in on the issue I filed seeking some consistency and provided the link to the Git commit where the MENU key change was added.

Developers may want to have consistency in the behavior of their app going back to previous versions of Android. The standard code snippet people have been using to trick the action bar into showing the “…” is:

try {
  ViewConfiguration config = ViewConfiguration.get(this);
  Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");

  if (menuKeyField != null) {
    menuKeyField.setAccessible(true);
    menuKeyField.setBoolean(config, false);
  }
}
catch (Exception e) {
  // presumably, not relevant
}

Personally, I still would not use it. While some users have not discovered the MENU key, many have. While you may be getting complaints from some users, you are unlikely to be getting positive feedback (“hey, thanks for supporting the MENU key!”), and so over-reacting to the complaints amounts to selection bias. And by introducing this hack, you may wind up with the same number of complaints, now questioning why you have two different versions of the same menu (one in the “…” drop-down, one from the MENU key). That being said, since the direction of Android is now to use the “…” affordance for all devices, I cannot quibble with developers who wish to have that behavior occur on older Android versions.