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 }
如果我将上述调用中的最后一个参数从更改为其他蓝牙配置文件,例如,则服务监听器会收到回调onServiceConnected,并且不会显示任何错误。1. 有没有人在Android Pie上创建过可工作的HID_DEVICE? 2. 可以使用BluetoothHidDevice在Android Pie手机上创建hid设备吗? 3. 是否有任何可以查看的工作代码? 4. 我的手机是否缺少某些功能(getPackageManager().hasSystemFeature)? 5. 上述错误的原因可能是什么?
任何提示都将不胜感激 :)
这似乎是第三方问题。诺基亚没有在Android Pie上启用hid配置文件。我还尝试了Mototorola G7 play,它也被禁用了,我想现在该用像素了...
android:enabled="@bool/profile_supported_hidd"
,而bool设置为false)。我通过setComponentEnabledSetting
解决了这个问题。 - ralismark