Android: BLE 清除取消自动连接

Android: BLE clear cancel autoConnect

在我的应用程序中,我使用自动连接在 BLE 设备可用时立即连接。

如何在需要时取消自动连接

我的自动连接代码:

bluetoothAdapter.getRemoteDevice(macAddress).connectGatt(this, true, callBack)

如何取消?

您只需在返回的 BluetoothGatt 对象上调用 disconnect()。

如果您不再需要 BluetoothGatt 对象,请调用 close() 以释放蓝牙堆栈中的资源。