Android Bluetooth Scan for classic and BTLE devices

Android documentation states:

Note: You can only scan for Bluetooth LE devices or scan for Classic Bluetooth devices, as described in Bluetooth. You cannot scan for both Bluetooth LE and classic devices at the same time. 

However, I notice that the call to mBtAdapter.startDiscovery (); both classic and btle devices are returned. Does anyone know what is right here?

+7
android android bluetooth bluetooth-lowenergy discovery
source share
1 answer

From my understanding of what documentation means, you cannot startLeScan () and startDiscovery () works at the same time. The reason may be that there is only one BluetoothAdapter object (an object representing local Bluetooth equipment), so it cannot perform two different operations that use the BluetoothAdapter at the same time. (If someone knows something else regarding how he works in the background, let us know)

startLeScan () -> scan only for BLE devices
startDiscovery () → detects all Bluetooth devices, it also scans for only 12 seconds, and this cannot be changed (read the method description)

Note. . After scanning the startDiscovery () request when a BT device is found, you can get the device type to determine what each device is. For example:

  int deviceType = device.getType(); if(deviceType == BluetoothDevice.DEVICE_TYPE_CLASSIC) { } else if(deviceType == BluetoothDevice.DEVICE_TYPE_LE) { } else if(deviceType == BluetoothDevice.DEVICE_TYPE_DUAL) { } else if(deviceType == BluetoothDevice.DEVICE_TYPE_UNKNOWN) { } 
+9
source share

All Articles