问题描述
我正在尝试使用Bluetooth HID设备配置文件服务编写用于Android P的应用程序,以用作Bluetooth键盘.根据文档,我应该使用方法BluetoothAdapter.getProfileProxy(Context, BluetoothProfile.ServiceListener, int)
来获取BluetoothHidDevice代理对象.
I am trying to write an app for Android P using the Bluetooth HID device profile service to be used as a Bluetooth keyboard. According to the documentation I am supposed to use the method BluetoothAdapter.getProfileProxy(Context, BluetoothProfile.ServiceListener, int)
to get the BluetoothHidDevice proxy object.
在我的Android Pie设备(Nokia 7 plus)上调试期间,服务监听器永远不会被调用(onServiceConnected
),并且在Logcat中出现以下错误:
During debug on my Android Pie device (Nokia 7 plus) the service listener never get called (onServiceConnected
), and i get the following error in Logcat:
Could not bind to Bluetooth HID Device Service with Intent { act=android.bluetooth.IBluetoothHidDevice }
如果我将上述通话中的最后一个参数从 HID_DEVICE 更改为其他蓝牙配置文件,例如 A2DP ,服务侦听器将获得回调onServiceConnected
,并且不会显示错误.
If I change the last param in the call above from HID_DEVICE to some other bluetooth profile e.g. A2DP, the service listener get the callback onServiceConnected
and no error is displayed.
- 有人在Android Pie上创建了有效的HID_DEVICE吗?
- 可以使用
BluetoothHidDevice
在Android上创建隐藏设备派电话? - 有什么我可以看的工作代码吗?
- 是否有某些功能(
getPackageManager().hasSystemFeature
)我的手机不见了吗? - 上面的错误可能是什么原因?
- Has anyone created a working HID_DEVICE on Android Pie?
- Can
BluetoothHidDevice
be used to create a hid-device on an AndroidPie phone? - Is there any working code that i can look at?
- Is there some feature (
getPackageManager().hasSystemFeature
)missing in my phone? - What could be the reason for the error above?
任何提示将不胜感激:)
Any hints would be greatly appreciated :)
这似乎是第三方问题.诺基亚未在Android Pie中启用隐藏配置文件.我还尝试了Mototorola G7播放,它也被禁用了,我想现在该是像素了……
This seems to be a third-party issue. Nokia did not enable the hid-profile in Android Pie. I also tried with a Mototorola G7 play, it was also disabled, i guess it's time for a pixel...
推荐答案
当前在像素上启用了HID设备配置文件.据我所知,诺基亚,moto(如上所述)以及One Plus 5T和6不支持此配置文件.
Currently on pixel the HID device Profile is enabled . Nokia, moto(as mentioned above) and One Plus 5T and 6 as far as i know dont support this profile.
我们创建了一个应用程序,您可以通过此HID设备配置文件将手机用作蓝牙鼠标和键盘. https://play.google.com/store/apps/details?id = com.github.roarappstudio.btkontroller
We have created an app which lets you use your phone as a bluetooth mouse and keyboard with this HID device profile.https://play.google.com/store/apps/details?id=com.github.roarappstudio.btkontroller
该代码在 https://github.com/raghavk92/Kontroller 上开源.如果有人想帮助您进行改进或为代码做出贡献,则欢迎他们.
The code is open sourced at https://github.com/raghavk92/Kontroller. If anyone wants to help in making improvements or contribute to the code they are welcome.
您还可以通过该应用检查手机是否支持蓝牙HID设备配置文件- https://play.google.com/store/apps/details?id=com.rkaneapplabs.bluetooth_hid.bluetoothproxy ,并让您的设备制造商知道他们是否不支持您的设备,因为其android pie的一部分,应该受到支持.
You can also check if your phone supports Bluetooth HID device profile with the app - https://play.google.com/store/apps/details?id=com.rkaneapplabs.bluetooth_hid.bluetoothproxy and let your device manufacturer know if they dont support your device because its part of android pie and should be supported.
这篇关于如何在Android Pie中使用Bluetooth HID设备配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!