如何在Android Pie中使用蓝牙HID设备配置文件?

问题描述 投票:7回答:1

我正在尝试使用蓝牙HID设备配置文件服务为Android P编写应用程序,以用作蓝牙键盘。根据documentation我应该使用方法BluetoothAdapter.getProfileProxy(Context, BluetoothProfile.ServiceListener, int)来获取BluetoothHidDevice代理对象。

在我的Android Pie设备(Nokia 7 plus)上调试期间,服务侦听器永远不会被调用(onServiceConnected),我在Logcat中收到以下错误:

Could not bind to Bluetooth HID Device Service with Intent { act=android.bluetooth.IBluetoothHidDevice }

如果我将上面调用中的最后一个参数从HID_DEVICE更改为其他一些蓝牙配置文件,例如A2DP,服务侦听器获取回调onServiceConnected并且不显示错误。

  1. 有人在Android Pie上创建了一个有效的HID_DEVICE吗?
  2. 可以使用BluetoothHidDevice在Android Pie手机上创建一个隐藏设备吗?
  3. 我可以看一下工作代码吗?
  4. 我的手机中是否缺少某些功能(getPackageManager().hasSystemFeature)?
  5. 上述错误可能是什么原因?

任何提示将不胜感激:)

这似乎是第三方问题。诺基亚没有启用Android Pie中的隐藏配置文件。我也尝试过Mototorola G7游戏,它也被禁用,我猜是时候像素...

android android-bluetooth hid
1个回答
0
投票

你可以看看这个https://github.com/kshoji/BLE-HID-Peripheral-for-Android。我能够建立一个蓝牙键盘。


0
投票

目前在像素上启用HID设备配置文件。诺基亚,moto(如上所述)和One Plus 5T和6据我所知不支持此配置文件。

我们创建了一个应用程序,可让您将手机用作具有此HID设备配置文件的蓝牙鼠标和键盘。 https://play.google.com/store/apps/details?id=com.github.roarappstudio.btkontroller

该代码在https://github.com/raghavk92/Kontroller开源。如果有人想帮助改进或贡献代码,欢迎他们。

您还可以检查您的手机是否支持蓝牙HID设备配置文件与应用程序 - https://play.google.com/store/apps/details?id=com.rkaneapplabs.bluetooth_hid.bluetoothproxy,并让您的设备制造商知道他们是否不支持您的设备,因为它的部分Android安装和应该支持。

© www.soinside.com 2019 - 2024. All rights reserved.