android - BLE startLeScan() : null

标签 android bluetooth bluetooth-lowenergy android-bluetooth

现在我正在研究 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/

相关文章:

android - 无法将 firebase 与具有 flavor 和尺寸的即时应用程序连接

android - 将方法存储在单独的文件中。安卓

android - 我可以通过蓝牙同时向多个设备发送消息吗?

java - PC (Java) 和 Android 之间的蓝牙传输速度缓慢

java - Android +4.0 中的日历

android - 测试Android类时如何使用 Intent ?

ios - 为什么iOS BLE通信时会出现这么多NSNotification,如何释放?

c# - BlueTooth LE 4.0 (C# .NET) 的框架 (API)

android - 如何通过蓝牙或 BLE 在两个 Android 设备之间发送消息?

Android 4.3 BLE 计步器配置文件