Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected new behavior: startRangingBeacons in BeaconManager must be called on the main thread #1213

Open
gerardmundo-birket opened this issue Nov 21, 2024 · 1 comment

Comments

@gerardmundo-birket
Copy link

This change probably comes from commit 6c0aa93 "Merge branch 'bugfix/repeadly-scan-job-restart-on-navigation'"

Expected behavior

No crash when calling startRangingBeacons from a non-UI thread. This was the case until pulling "recent" code changes.

Actual behavior

Crash
java.lang.IllegalStateException: Method addObserver must be called on the main thread
at androidx.lifecycle.LifecycleRegistry.enforceMainThreadIfNeeded(LifecycleRegistry.kt:296)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:174)
at org.altbeacon.beacon.powersave.BackgroundPowerSaverInternal.(BackgroundPowerSaverInternal.java:44)
at org.altbeacon.beacon.BeaconManager.ensureBackgroundPowerSaver(BeaconManager.java:2088)
at org.altbeacon.beacon.BeaconManager.startRangingBeacons(BeaconManager.java:1186)

Steps to reproduce this behavior

Call startRangingBeacons from a non-UI thread

Mobile device model and OS version

Samsung Galaxy Tab Active2 on Android 8.1.0

Android Beacon Library version

Latest code in repo

IMPORTANT: This forum is reserved for feature requests or reproducible bugs with the library itself. If you need help with using the library with your project, please open a new question on StackOverflow.com.

@VolodaUa
Copy link
Contributor

Hi @gerardmundo-birket

Thanks for noticing it. I've created the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants