Bluetooth Low Energy Android - Search in Background
Asked Answered
S

1

2

I would like to know whether it is possible to check in the background if someone enters or leaves the a beacon Region?

In iOS for example you can use the methods didEnterRegion or didExitRegion to send notifications from the background.

Is there any native possibility or has someone a workaround?

Sylvanus answered 28/10, 2013 at 14:57 Comment(0)
W
1

Android doesn't have any "native" iBeacon capability at all, but you can see iBeacons using my company's open source Android iBeacon Library, which has APIs similar to those native to iOS 7.

In the case of iOS, the CLLocationManagerDelegate gives you access to the didEnterRegion and didExitRegion callbacks that you describe. In the Android iBeacon Library, the equivalent is the MonitorNotifier interface that gives you the same callback methods.

Making these callbacks successfully fire for apps that aren't in the foreground is a little tricky on both iOS and Android. On Android, you need to start a service of your own that runs when the Android device starts up, and bind to the IBeaconManager in that service.

Setting this up isn't super easy, so we developed a Pro Android iBeacon Library that does all this automatically. Examples are here.

EDIT: Both libraries above have been discontinued in favor of the free and open source Android Beacon Library which has all the feature of the pro library described above.

Whelm answered 29/10, 2013 at 3:0 Comment(5)
Thanks for your answer and nice work with your library. I will try your suggestion with an auto start service.Sylvanus
davidgyoung, how are you going with that example template and helpers?Tavi
I have a working version now. Please email me (David Young) at [email protected] if you would like to try out a beta version of this. I am developing it as part of a "pro" version of the Android iBeacon Library.Whelm
@davidgyoung: I'm trying to get a similar question answered[1]. What would this 'role your own' solution look like? You need to wake up the device, scan for some period of time and then stop the scanner, right? Can the main CPU sleep while the scanner is running? [1]stackoverflow.com/questions/19914244Demonism
I updated my answer above to point to the pro library which does all this and has been released. I also answered your other question about how you can use it for your problem.Whelm

© 2022 - 2024 — McMap. All rights reserved.