关于蓝牙的一些疑惑
发布于 6 年前 作者 jie89 7872 次浏览 来自 问答

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

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

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

1 回复

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

回到顶部