Closed mspapant closed 2 years ago
The custom code shown in this issue is very different from the official Java reference app for this library, so helping debug a custom app is out of scope for this forum. If you can make a reproducible test case with minimal modifications to that reference app, we can re-open this issue.
Three important points:
The second log snippet does not indicate that the library's "scanning changed to background mode".
The MIUI operating system is a heavily modified version of Android with undocumented limits on background processing. You may be seeing a proprietary limitation on background scanning. Read more here
The sample code shown uses several deprecated methods including RegionBoostrap
and direct calls to bind
and unbind
. Using these deprecated methods add lots of complexity and subtle timing issues and are a common source of bugs. This is why they are deprecated. I would highly recommend refactoring to use these to use the new autobind APIs. Read here for more info.
Deprecated methods continue to exist in the library for backward compatibility only. While you are welcome to continue using them if needed, it will be increasingly hard to get help from others for using them as time goes on.
Expected behavior
The beacon scanning it's supposed to work in foreground, since a foreground service has been started (foreground scanning mode)
Actual behavior
The scanning works foreground for a couple of minutes, but then is automatically switched to background mode. I see lot of log entries:
But after 3.5 minutes scanning changed to background mode and i can see the follow logs:
Steps to reproduce this behavior
This is the code that initiate the scanning:
When user opens the bluetooth i call:
Mobile device model and OS version
Android 12 - MIUI 13
Android Beacon Library version
2.17.1
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.