Android: Programmatically detect if device has hardware menu button

NiThDi picture NiThDi · Jan 28, 2012 · Viewed 32.7k times · Source

I'm currently struggling with this issue. I need to check if the device, where the app is installed, has a hardware menu key. Because it is not existing on some devices like Galaxy Nexus, I'm showing it directly in the UI in this case.

I have already looked at PackageManager.hasSystemFeature(), but didn't find anything useful there.

Has anyone already done this?

Answer

fhucho picture fhucho · Feb 28, 2012
ViewConfiguration.get(context).hasPermanentMenuKey()

See ViewConfiguration#hasPermanentMenuKey() for more information. Note that this is only available for API level 14+ (Android 4.0 Ice Cream Sandwich or newer).