I'm developing an app which provides background Beacon monitoring. I would like to start ranging when user enters beacon from defined region. When app is in background and it's monitoring all the time and user enters my defined region I would like to start ranging and get InstanceID or Major, Minor value to determine what beacon is that, connect to server and send user a notfication. The best would be if I could range and communicate with server in background. I used this sample to achieve background monitoring: https://altbeacon.github.io/android-beacon-library/samples.html. I also downloaded sample project from here: https://github.com/AltBeacon/android-beacon-library-reference to base on it.
Unfortunately in this example when user enters the region Activity is launched... I don't want that to happen. Soo my question is: Is it possible to range beacons in background?
Also weird thing happens in my case beacause when I put my app in background method "didRangeBeaconsInRegion(Collection beacons, Region region)" is still called from MainActivity but no beacon is found. Also method is called less often because beaconManager is in background mode. When I launched sample project that was not happening. Maybe it's because I don't have monitoringActivity. My MainActivity does ranging instantly when launched. Of course I tried to setup everything exactly the same as it is in an example BeaconReferenceApplication.
BTW I'm testing my app on Nexus 5 with Android 6.0.1
Thank you in advance for any solutions!
I finally figured it out how to do this! Actually I was quite simple and I was doing it right from the begining but by a mistake I'v been using old version of Altbeacon library and that caused all my problems... Ehh
Never mind. Here is my code. Meybe someone could use it ;) I made it by creating centralized Application class which implements BootstrapNotifier for background notifications when entering defined Region. My class also implements interfaces BeaconConsumer, RangeNotifier which are necessery to do beacon ranging.