AltBeacon / android-beacon-library

Allows Android apps to interact with BLE beacons
Apache License 2.0
2.83k stars 834 forks source link

Need to get beacon data When app Killed #1144

Closed PriyankaInoid closed 10 months ago

PriyankaInoid commented 1 year ago

Expected behavior - Need to get beacon data When app Killed

Actual behavior - When my app is in Terminated state foreground service is working and I am able to fetch location and network call is also working. But not able to fetch beacons in ranging Observer and beacon state in monitoring observer. Ranging Observer is working but no beacons data found when my app is terminated. It's working in background state but not in terminated state of app.

Steps to reproduce this behaviour

Mobile device model and OS version Galaxy M30 and OS version is 10

Android Beacon Library version implementation 'org.altbeacon:android-beacon-library:2.19'

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.

davidgyoung commented 1 year ago

Thank you for this report.

To clarify, how can these two things be true? "When my app is in Terminated state foreground service is working". If the app is terminated, then the foreground service must not be running, right?

Similarly, how can this be true? "Ranging Observer is working but no beacons data found when my app is terminated." If the app is terminated, you cannot be getting observer callbacks.

Do you mean to say that once your app resumes after termination that you get callbacks but the beacon list is unexpectedly empty?

You may wish to try this with the official Reference App to see if you can reproduce the same behavior. It is set up to use a foreground device, but does not do so by default. You have to uncomment these five lines in BeaconReferenceApplication.kt so it will use a foreground service:

        setupForegroundService()
        beaconManager.setEnableScheduledScanJobs(false);
        beaconManager.setBackgroundBetweenScanPeriod(0);
        beaconManager.setBackgroundScanPeriod(1100);

Once you do that, run it, and verify in logs you get beacon detections:

06-14 10:04:49.334  9609  9609 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 2.4047537514126427 meters away
06-14 10:04:50.438  9609  9609 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 2.473503832962466 meters away
06-14 10:04:51.542  9609  9609 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 2.4901690380924597 meters away
06-14 10:04:52.644  9609  9609 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 2.5453099611817005 meters away
06-14 10:04:53.648  9609  9609 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 2.544405812341515 meters away

After termination and auto-restart:

06-14 10:06:59.041 11572 11572 D BeaconReference: inside beacon region: id1: null id2: null id3: null
06-14 10:06:59.291 11572 11572 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 1.8308898002282419 meters away
06-14 10:07:00.395 11572 11572 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 1.7407265075763876 meters away
06-14 10:07:01.503 11572 11572 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 1.6877526602425696 meters away
06-14 10:07:02.607 11572 11572 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 1.6786169856013875 meters away
06-14 10:07:03.710 11572 11572 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 1.70220082589558 meters away
06-14 10:07:04.818 11572 11572 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 1.7977373873377747 meters away
06-14 10:07:05.926 11572 11572 D BeaconReference: id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 1 id3: 1 about 1.8601819786090381 meters away

You should see the same. Assuming you do, what is the difference in the setup between the Reference App and your app?

davidgyoung commented 10 months ago

closed due to inactivity