【发布时间】:2018-04-25 22:28:58
【问题描述】:
在 Android 系统设置中关闭蓝牙会给我们在 Android BluetoothGattCallback.onConnectionStateChange() 调用。但是,当我在 Pixel 或 Nexus 5X (Android 8.1.0) 上尝试时,我没有收到该回调。蓝牙代码是否有一些变化,在蓝牙设置更改时我们没有收到BluetoothProfile.STATE_DISCONNECTED 的通知。我注意到设备断开连接。此外,当关闭 BLE 设备时,回调会被调用。任何见解都值得赞赏!
在此处作为问题提交Google Issue
【问题讨论】:
-
您必须在连接回调中检查
BluetoothGatt.STATE_DISCONNECTING或BluetoothGatt.STATE_DISCONNECTED而不是BluetoothProfile -
@HawkPriest
BluetoothGatt和BlueoothProfile都对STATE_DISCONNECTED使用相同的常量。BluetoothGatt实现BluetoothProfile。 -
你能解决这个问题吗?我也遇到了同样的问题。
-
@Adrian 我不是,我不知道他们是否有任何解决方案。我还没来得及想出解决方案就离开了这个项目。
标签: android bluetooth android-bluetooth android-ble bluetooth-gatt