Comments (8)
@davidgyoung just FYI, I added the AltBeacon code locally to my project and updated the ANDROID_N_MIN_SCAN_CYCLE_MILLIS
to 10 seconds. With this change, the CycledLeScanner
starts only 3 times in the limited 30 second interval and we can therefore also start 2 additional scans in this interval. It seems to be working pretty good and we do not receive any App 'xxx' is scanning too frequently
anymore.
Since I have not received an answer yet I assume it is not planned to make this interval configurable. If that is the case feel free to just close this issue. Thanks and best regards
Julian
from android-beacon-library.
Apologies for the delayed response. I think your solution is fine, but a simpler solution may be to to disable the scan off/on behavior entirely.
The default foreground scan intervals are 1100ms on / 0ms off. The only reason the library turns off the scan momentarily between cycles in this case is because the first generation BLE Android devices from 2012 (Nexus 4, Moto G 1st Gen) would only allow be detection per device per scan. This problem has been solved for nearly 10 years now and very few affected devices still exist.
there may be an easy way to turn this off here:
Do you think this would solve your problem?
from android-beacon-library.
@davidgyoung thank you for your answer and your advice!
This would be an even better solution since it would simplify our logic with the delay to avoid the scanning too frequently
.
I just did a quick check and saw, that the flag mDistinctPacketsDetectedPerScan
is set to true on all of our test devices. However, the condition in the if statement also consists of the Android N timeout (mustStopScanToPreventAndroidNScanTimeout()
) and the mBetweenScanPeriod != 0
check. When you say turn it, do you mean to falsify the whole condition (if(false)
)?
from android-beacon-library.
The method mustStopScanToPreventAndroidNScanTimeout() just checks to see if a scan has been going on for 30 minutes, and if so returns true. This logic exists because Android N+ stops such long running scans automatically, requiring a stop and restart to avoid the OS cancelling. In short, I don’t think this part of the logic is a problem for you — it is something you want.
If you have mDistinctPacketsDetectedPerScan set to true, this is enough for your use case to work, yes?
The only trouble I can see is the his flag does not get set to true immediately after app start up. The library must first detect 2+ beacon packets in one scan cycle. And until this happens, the library will be cycling scans on and off at the max rates allowed, possibly interfering with your app’s other scans.
So my proposal is to offer a quicker way to set this flag to true. As far as I know, it should be true for all modern Android devices. Unfortunately there is no way to easily detect if an Android device is modern, but there are proxies, such as the ability to run a more recent Android OS version.
from android-beacon-library.
One idea would be to set the flag to true by default for all Android 6+ devices (the Nexus 4, one of the devices which needs to be false, never received Android 6). However there could in theory be some folks running old Nexus 4s on Lineage OS based on Android 11… I am aware of at least two cases where companies have bought up lots of old older phones for use with this library as dedicated beacon scanners.
Obviously this would be unusual. But the fix needed is also for a somewhat usb usual use case. I am just trying to figure out a fix to support a relatively unusual use case that doesn’t cause new problems on other unusual use cases.
from android-beacon-library.
@davidgyoung I just tried to set the flag mDistinctPacketsDetectedPerScan
immediately (hardcoded) to true
however this doesn't change anything because the field mBetweenScanPeriod
always has the value 50, therefore the condition mBetweenScanPeriod != 0
is true
which makes the whole condition true
.
Assuming that the flag mDistinctPacketsDetectedPerScan
works as expected, could it maybe work to just remove the condition mBetweenScanPeriod != 0
? If I am totally wrong on this please let me know if I am missing something. Thanks!
from android-beacon-library.
Ok, yeah, what you say is true if you set a custom between scan period to 50ms. Must you do this? Why not leave it at 0ms, which is the default.
from android-beacon-library.
@davidgyoung I wasn't aware we made this change, sorry and thanks for pointing it out!
As you suggest I will update the period to 0 and set the flag hardcoded to true. Thank you very much for detailed help, I appreciate a lot!
Since the logic should already work as expected and therefore no change for the library is required I will now close this GH issue.
BR
Julian
from android-beacon-library.
Related Issues (20)
- BLE Beacon scanning when app is killed HOT 1
- Stop detecting iBeacons when app is terminated after 30 minutes HOT 2
- RangedBeacon getFilter() HOT 13
- NPE crash in latest version (2.20.1) in StartupBroadcastReceiver HOT 1
- Range beacons when app is terminating HOT 7
- Beacons ranging not working on android 13 HOT 1
- App stops scanning right after screen is locked and starts giving the results right after unlocked HOT 1
- Android beacon library - multiple regions monitoring - unable remove regions HOT 2
- startForeground Exception when app is not in foreground HOT 3
- StartupBroadcastReceiver throws NullPointerException HOT 2
- No beacons after locked screen HOT 19
- Cannot parse iBeacons HOT 3
- BeaconService.startForegroundIfConfigured HOT 12
- TargetSdk 34 (android 14) Beacon foreground service no longer working due to new Google restriction HOT 1
- Do we have sample app to implement the library including the operation running in Background HOT 4
- Only a maximum of 2 beacons can be received at a time HOT 1
- java.io.FileNotFoundException android-distance.json HOT 3
- android-distance.json database not found
- Crash when parsing _lengthy_ beacon data fields HOT 3
- Custom Distance calculator is being overwritten HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-beacon-library.