Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect whether an Android device have been connected with an external keyboard?

In my app, I have to detect whether an external keyboard is connected to the device to determine what to show to users.

I know the soft keyboard will not show if an external keyboard is connected on my device, Xoom android 3.1.

How can I know whether an Android device have been connected with an external keyboard through an USB or Bluetooth?

Thanks!

like image 826
Small Archer Avatar asked Dec 08 '25 07:12

Small Archer


1 Answers

you can find out if a bluetooth keyboard is connected to android device with getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;

if it returns true then bluetooth keyboard is connected, false otherwise.

like image 152
Sherry Avatar answered Dec 09 '25 19:12

Sherry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!