关于蓝牙的一些疑惑

发布于 8 年前作者 jie898054 次浏览最后编辑 8 年前来自 ask

我们往往会在onBluetoothAdapterStateChange 中监测到蓝牙设备可用后去开启startBluetoothDevicesDiscovery搜索设备,

但是本身startBluetoothDevicesDiscovery和stopBluetoothDevicesDiscovery同时都会引发onBluetoothAdapterStateChange事件

应该如何设计逻辑避免循环调用

1 回复
chengjing
chengjing1 楼6 年前

你可以根据onBluetoothAdapterStateChange中返回的discovering值进行判断,true表示startBluetoothDevicesDiscovery,false表示stopBluetoothDevicesDiscovery