In recent versions of Android it's possible for devices to either have software or hardware buttons. I'd like to find out which is the case for the device my app is running on.

Some background information: It is possible to hide the softkeys as they are displayed on the screen but if you do this they automatically get shown if the user touches the display which is perfectly fine. Now if you do the same on a device with hardware keys the first touch still gets caught by the system like as if it would show the softkeys again but as there are none, nothing happens and the touch event does not get passed to the app.

有帮助吗?

解决方案

You could use ViewConfiguration.hasPermanentMenuKey(), to check for a menu key.

其他提示

For the Keyboard-question try

getResources().getConfiguration().keyboard

that gives you one of the following:

  • KEYBOARD_NOKEYS
  • KEYBOARD_QWERTY
  • KEYBOARD_12KEY

check for KEYBOARD_NOKEYS.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top