1



I have HID BLE keyboard which normally when I want to connect to it in android os environment, I go to Bluetooth page, search for it then tap on keyboard name and connect to it.
now I want to know that can I write an app that automatically finds the device and then connect to it as an input device or not?

I'm already read the documents about BLE communication in Android, but none of them does not explain how to connect HID keyboard as an input device looks like android itself connect to it.

Mr. Ad
  • 333
  • 3
  • 12
destrat18
  • 197
  • 2
  • 14

2 Answers2

1

No the public API does not allow you to activate the "use as only device" switch shown in the Android Bluetooth Settings UI.

However up to Nougat you can do it with Reflection. Just read the source code of the Settings app and do the same thing.

Emil
  • 16,784
  • 2
  • 41
  • 52
  • as you said, my only way to do this job is reading the source code of Android itself? there is no official approach? – destrat18 Jun 20 '18 at 05:05
0

Yes! you can search the nearby bluetooth devices and you can connect to the device. The transmitting of data is depends on the Device UUID. as per bluetooth standards bluetooth UUID standards you need to use UUID = 00000011-0000-1000-8000-00805F9B34FB to connect HID devices

Here is the link for a sample project.

Chethan Kumar
  • 185
  • 1
  • 12
  • I've already checked android BLE documentation. as i said in question i need to connect to it as input device not only BLE device. – destrat18 Jun 20 '18 at 05:07