[Interest] Detect connected Bluetooth keyboard under Android

Alex Blasche alexander.blasche at qt.io
Tue Oct 30 08:24:12 CET 2018


As a disclaimer I have not really done any HID work on Android, but based on the Android docs you need to use the BluetoothHidDevice class to interact with such keyboards. BluetoothHidDevice.Callback.onConnectionStateChanged is probably what you need.

This Android API is not available via Qt APIs. QBluetoothLocalDevice is for the local Bluetooth device which is not the remote Bluetooth keyboard and HID connects/disconnects cannot be done programmatically by design. The user has to make the connection manually. Therefore I am assuming the platform does not expose such devices via the usual discovery mechanisms either. You have to write your own Java/JNI code to interact with the class.

--
Alex

________________________________________
From: Interest <interest-bounces+alexander.blasche=qt.io at qt-project.org> on behalf of Roman Wüger <roman.wueger at gmx.at>
Sent: Monday, 29 October 2018 11:37:32 PM
To: Qt Project MailingList
Subject: [Interest] Detect connected Bluetooth keyboard under Android

Hi @all,

i played with the QBluetoothLocalDevice and QBluetoothDiscoveryAgent to detected if a Bluetooth keyboard is connected to an android tablet.

However, I can’t find out the correct way. I tried to read the majordeviceclass and minordeviceclass but it doesn‘t work, I only get 31,0 but the documentation says that 5 should be the major device class. The keyboard works in any input fields, but I can‘t find it.

I only need a signal if a keyboard connects/disconnects like hardwareKeyboardConnected(bool)

What do I need for that?

Thanks in advance
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list