Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm using BluetoothLeScanner to scan for BLE devices, which I start using:

startScan(null, settings.getScanSettings(), scanCallback);

Every once in a while, a call to startScan() does not discover any BLE device, even though some devices are actually advertizing (They are discovered using nRF Connect app).

When this happens, the next call to stopScan() and startScan() does discover devices.

I know that since Android 7, the number of start and stop scans is restricted to 5 times in a window of 30 seconds. However, I've noticed the problem occurs also if no stopScan()/startScan() has not been called for more than 30 secs.

Has anyone experienced such issue ? Could it be something else my app is doing while starting the scanner that could the scanning to fail ?

I have this problem using Android 10 and lower versions.

question from:https://stackoverflow.com/questions/65941190/android-why-is-bluetoothlescanner-sometimes-not-discovering-any-ble-device

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

Android phone limited BLE scan duration to save energy. So you can not scan BLE advertising for a long time. It is system limitation so APP layer have no way to change that.

In older phone (maybe under 4.4) do not set the limitation, but it will make the phone getting hot.

If you want to scan BLE advertisement for a long time, change your design is a better way.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...