Android – Always show the overflow menu even if the phone has an options button

If an Android device has an option button, the overflow menu is not shown.

While it it not recommended as the user except a certain behavior from his device, you can trick you device in thinking it has no option button with the following code.

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) {
e.printStackTrace();
}
}

Source Stackoverflow

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Android. Bookmark the permalink.

One Response to Android – Always show the overflow menu even if the phone has an options button

  1. Daniel Zimmermann says:

    Interessting – I guess I will give it a try.
    Maybe (to not completly confuse Samsung users) it would better, if both approaches (menu button and overflow menu) still would function. But maybe this would end in a usability catastrophy…

Comments are closed.