question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scan failed: a BLE scan with the same settings is already started by the app

See original GitHub issue

Expected behavior

No error in logs about scan already started

Actual behavior

@paulpv: “I am confused by the behavior that I am seeing when I background the app while a scan is active. With a scan active/started, I background the app and almost immediately get this…”

2020-01-28 14:50:21.042 17590-17590/org.altbeacon.beaconreference D/CycledLeScanner: Done with scan cycle
2020-01-28 14:50:21.044 17590-17590/org.altbeacon.beaconreference D/CycledLeScanner: Not stopping scan because this is Android N and we keep scanning for a minimum of 6 seconds at a time. We will stop in 3773 millisconds.
2020-01-28 14:50:21.045 17590-17590/org.altbeacon.beaconreference D/CycledLeScanner: starting a new scan cycle
2020-01-28 14:50:21.045 17590-17590/org.altbeacon.beaconreference D/CycledLeScanner: restarting a bluetooth le scan
2020-01-28 14:50:21.047 17590-17590/org.altbeacon.beaconreference D/CycledLeScannerForLollipop: starting a scan in SCAN_MODE_LOW_LATENCY
2020-01-28 14:50:21.049 17590-17590/org.altbeacon.beaconreference D/CycledLeScannerForLollipop: Using a wildcard scan filter on Samsung because the screen is on.  We will switch to a non-empty filter if the screen goes off

The log says it isn’t going to stop the scan, but what it does is start a scan while a scan is already scanning, which results in onScanFailed SCAN_FAILED_ALREADY_STARTED the the following log:

2020-01-28 14:58:50.950 17590-17590/org.altbeacon.beaconreference E/CycledLeScannerForLollipop: Scan failed: a BLE scan with the same settings is already started by the app

I have yet to find a way to get startAndroidOBackgroundScan to be called. 😕

Steps to reproduce this behavior

Run the reference app on a Samsung device with the screen on

Mobile device model and OS version

Samsung

Android Beacon Library version

2.16.4

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
davidgyoungcommented, Jan 30, 2020

Yes, a BeaconParser is a requirement for getting background detections with this library. The setNonBeaconLeScanCallback is provided as a convenience method for apps that also need non-beacon BLE detections, so they apps don’t have to set up secondary beacon scanning. But this is a secondary function of the library provided only for convenience, and is certainly not a core function.

0reactions
paulpvcommented, Jan 29, 2020

I am using setNonBeaconLeScanCallback and clearing all beacon parsers. I get scan results for everything except when the screen is off. I do understand that scanning w/ the screen off is tricking on some phone brands and may need a special non-wildcard filter.

I can and will create a parser for my own BLE device, which isn’t always a beacon, but thought I would avoid that for now and just try to prove out if this library meets my requirements. If it is a requirement of this library to provide a valid beacon parser then I will go ahead and create a custom one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scan failed: app cannot be registered (Alt-Beacon Library ...
1 Answer 1 ... Unfortunately, this appears to be an internal error in Android, indicating something is wrong with the bluetooth stack. One...
Read more >
ScanCallback - Android Developers
Fails to start scan as BLE scan with the same settings is already started by the app. ... Callback when a BLE advertisement...
Read more >
No devices found during BLE scan on android 10
I have to grant access in the Android settings. In the settings location-access is granted while app is in use. It's the same...
Read more >
BLE scan may freeze randomly | Apple Developer Forums
Users can enable an automatic command while the app is in the background. This automatic command triggers if the device hasn't been detected...
Read more >
android.bluetooth.le.ScanCallback.java Source code
Source ; ScanCallback { /** * Fails to start scan as BLE scan with the same settings is already started by the app....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found