有没有办法在Android中判断一个用户设备具有实际的键盘或不? [英] Is there a way in Android to tell if a users device has an actual keyboard or not?
问题描述
我想检测,如果当前用户的手机有硬件键盘或仅在屏幕键盘。这可能与SDK?
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?
推荐答案
是,您可以。
取的<一个href="http://developer.android.com/reference/android/content/res/Configuration.html">Configuration使用对象
Configuration config = getResources().getConfiguration();
...然后看看<一href="http://developer.android.com/reference/android/content/res/Configuration.html#keyboard"><$c$c>keyboard$c$c>领域。
如果他们看重的<一个href="http://developer.android.com/reference/android/content/res/Configuration.html#keyboard"><$c$c>keyboard$c$c>是不是<一个href="http://developer.android.com/reference/android/content/res/Configuration.html#KEYBOARD_NOKEYS">KEYBOARD_NOKEYS,用户有硬件键盘。
If they value of keyboard
is not KEYBOARD_NOKEYS, the user has a hardware keyboard.
请注意,由于 @Carl 说,在他的评论如下,用户可以在同时任何时候连接USB键盘您应用程序正在运行,从而导致键盘
的值来改变。
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.
这篇关于有没有办法在Android中判断一个用户设备具有实际的键盘或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!