Skip to content

Instantly share code, notes, and snippets.

@kbshl
Created November 25, 2016 15:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbshl/028d6a1824ca374e1308136c5c6ddbdc to your computer and use it in GitHub Desktop.
Save kbshl/028d6a1824ca374e1308136c5c6ddbdc to your computer and use it in GitHub Desktop.
Force options menu in ActionBar on devices which have hardware menu button - From http://stackoverflow.com/questions/26010876/options-menu-does-not-appear-in-action-bar-on-some-devices/26011059#26011059
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception ex) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment