在 android 中实用地连接到 HID 键盘设备作为输入设备

connect to HID keyboard device as input device in android pragmatically



我有 HID BLE 键盘,通常当我想在 android os 环境中连接它时,我会转到蓝牙页面,搜索它然后点击键盘名称并连接它。
现在我想知道我是否可以编写一个自动查找设备然后将其作为输入设备连接的应用程序?

我已经阅读了 Android 中关于 BLE 通信的文档,但是其中 none 没有解释如何连接 HID 键盘,因为输入设备看起来 android 本身连接到它。

是的!您可以搜索附近的蓝牙设备并连接到该设备。 数据的传输取决于设备 UUID。根据蓝牙标准 bluetooth UUID standards 你需要使用 UUID = 00000011-0000-1000-8000-00805F9B34FB 来连接 HID 设备

Here is the link for a sample project.

否 public API 不允许您激活 Android 蓝牙设置 UI 中显示的 "use as only device" 开关 UI。

但是直到牛轧糖,您都可以使用反射来完成。只需阅读设置应用程序的源代码并执行相同的操作即可。