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
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
}
}