Can anyone please tell me if there is any way we can find out if a bluetooth QWERTY keyboard is attached to android device.
I tried working with getResources().getConfiguration.keyboard, but it always gives me the same value whether key board is attached or not.
Thanks
Bluetooth Keyboard to Android – PairingYou can pair a bluetooth keyboard easily, as you pair any bluetooth device. First, go to Settings and enable Bluetooth in your device. Then, your phone or tablet will detect the available Bluetooth keyboard and pairing will be done almost automatically.
Via Bluetooth For this method, you will need to buy a Bluetooth keyboard setup. There are many good options on the market. These keyboards come in small, medium and regular sizes and work reliably well, with long battery life. Once you have a Bluetooth keyboard, turn it on to make it discoverable.
One way to do this is adding android:configChanges="keyboard"
to the activity in your AndroidManifest.xml file.
With this you can override onConfigurationChanged
which will be called whenever a keyboard is plugged in or plugged out
@Override
public void onConfigurationChanged(Configuration newConfig)
{
if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
//A hardware keyboard is being connected
}
else if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
//A hardware keyboard is being disconnected
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With