问题
I would like to detect if the current users phone has a hardware keyboard or only a on-screen keyboard. Is this possible with the SDK?
回答1:
Yes, you can.
Fetch the Configuration object using
Configuration config = getResources().getConfiguration();
...and then look at the keyboard field.
If they value of keyboard is not KEYBOARD_NOKEYS, the user has a hardware keyboard.
Note that as @Carl says in his comment below, the user may attach a USB keyboard at any point while your app is running, causing the value of keyboard
to change.
来源:https://stackoverflow.com/questions/6654177/is-there-a-way-in-android-to-tell-if-a-users-device-has-an-actual-keyboard-or-no