uni.onBluetoothDeviceFound(CALLBACK) API接口得到重复蓝牙名称 #1988
Closed
Description
在调试安卓APP时,在使用uni.onBluetoothDeviceFound(CALLBACK) 监听寻找到新设备的事件时,第一次开启蓝牙模块监听时得到的蓝牙名称是正确的,在关闭蓝牙,再开启蓝牙模块,接着再监听寻找到新设备的事件时同一个蓝牙会得到2次相同名称的结果。再开启蓝牙模块,接着再监听寻找到新设备的事件时同一个蓝牙会得到3次相同的名称结果......N此,同一个蓝牙就会n次相同的结果。这样是不对的
调用蓝牙步骤:
1、uni.openBluetoothAdapter({}) //开启蓝牙设备
2、uni.getBluetoothAdapterState({}) //获取蓝牙状态
3、uni.startBluetoothDevicesDiscovery({}) //搜索蓝牙
4、uni.onBluetoothDeviceFound(function(devices) {} //监听蓝牙
5、console.log 蓝牙 //终端打印蓝牙名称,就是这里出错,按上面步骤,同一个蓝牙会打印多次
6、uni.stopBluetoothDevicesDiscovery({}) //关闭蓝牙搜索
7、uni.closeBluetoothAdapter({}) //关闭蓝牙设备
Metadata
Assignees
Labels
No labels