I connect bluetooth barcode scanner to my android tablet. barcode scanner is bonded with android device as a input device - HID profile. it shows as keyboard or mouse in system bluetooth manager. i discovered that bluetooth profile input device class exist but is hidden. class and btprofile constants have @hide annotaions in android docs.
hidden class:
here they should be also 3 other constants
developer.android.com/reference/android/bluetooth/BluetoothProfile.html#HEADSET
just like
public static final int INPUT_DEVICE = 4;
public static final int PAN = 5;
public static final int PBAP = 6;
that constants are simple accessible by reflection. What i need to achieve, is list of devices by hid profile(INPUT_DEVICE). it should be simple with small changes using method:
developer.android.com/reference/android/bluetooth/BluetoothA2dp.html#getConnectedDevices()
not for A2dp profile, but for hid profile accessed also by reflection methods. sadly
Class c = Class.forName("android.bluetooth.BluetoothInputDevice")
won't work.. any ideas how i should approach to the problem ? i need only list of hid devices
I figured out how to solve my problem. That was very helpful. First of all I needed to prepare reflection method which return input_device hidden constants of hid profile:
Instead of that function, I could use value 4, but i want to do it elegant.
Second step was to define listener of specific profile:
In third step I invoked
Everything clearly works and mProfileListener returns me list of specific profile bluetooth device/-es. Most interesting thing takes place in onServiceConnected() method, which returs object of hidden class BluetoothInputDevice :)