Reputation: 95
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!
Upvotes: 3
Views: 2513
Reputation: 3095
You need to use a BroadcastReceiver
and register it for an intent filter for Bluetooth actions. You will have to search the USB API for the other.
BroadcastReceiver
's onReceive method will handle these activities.
Upvotes: 1
Reputation: 326
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.
Upvotes: 4