0

BootstrapNotifier (i.e. MonitorNotifier) have callback for entering / exiting region but how to get the region state at app startup (how can app realize to be already IN a region)?

Roven
  • 7
  • 4

1 Answers1

0

As of Android Beacon Library version 2.8.1, the only way to do this is via accessing some internal library classes like this:

if (MonitoringStatus.getInstanceForApplication(this).stateOf(region) != null && MonitoringStatus.getInstanceForApplication(this).stateOf(region).isInside()) { // Do something }

I would recommend against using this in production code, as this internal API is subject to change. In the next version of the library will have a way to get this information on the BeaconManager as so:

beaconManager.requestStateForRegion(region);

The above method will cause a callback to be made on the MonitorNotifier or BootstrapNotifier: didDetermineStateForRegion(int state, Region region);

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Many thanks, really. It works! Even without replacing the "do something" section the didDetermineStateForRegion callback is called: very good. It's ok for tests and I'll wait for next release of library before going in production ;-) – Roven Jul 21 '16 at 08:08