现在我正在研究 BLE。我发现一个问题,它向我显示 startLeScan(): null
的日志并且扫描也不起作用我为此尝试了一切并搜索了 startLeScan(): null
但还没有得到任何解决方案。
这是我的 BLE 连接代码:
private void scanLeDevice(boolean enable) {
if (enable) {
mBluetoothAdapter.startLeScan(mLeScanCallback);
} else {
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
}
这是我发现这个东西的日志
01-27 13:12:21.357 4657-4657/com.icuisine D/BluetoothAdapter: stopLeScan()
01-27 13:12:23.003 4657-4657/com.icuisine D/BluetoothAdapter: startLeScan(): null
01-27 13:12:23.004 4657-4657/com.icuisine D/BluetoothAdapter: STATE_ON
01-27 13:12:23.007 4657-4668/com.icuisine D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
我浏览了很多网站,发现该类(class)现在已被弃用,但我不知道如何才能获得其他扫描方式。
我正在 Nexus 5 Ver Android 6.1 中进行测试,并且还应用了蓝牙的运行时权限。
我知道这是重复的问题,但我没有在原始问题中找到任何解决方案,这就是我重新发布它的原因!
希望这是足够的细节。需要帮助才能完成这件事。
提前致谢。
最佳答案
BluetoothAdapter.startLeScan
已弃用,可以使用 BluetoothAdapter.bluetoothLeScanner.startScan
解决问题。
关于android - BLE startLeScan() : null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41889181/