Вопрос

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