开发者

Is there a way in Android to tell if a users device has an actual keyboard or not?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜