vanste25
vanste25

Reputation: 1774

Android beacon library - multiple regions monitoring

I use Android beacon library so I need help with some matters:

If I understood correctly, we must have just one RegionBootstrap. Why? Is it possible to have a list of RegionBootstraps?

I tried to implement that and it works okay. What difficulties could arise from this approach?

Replacement for my logic would be one RegionBootstrap with multiple regions, but then I cannot remove all regions from it. Why did the author skip to add that?

I have guest mode and user mode and every of them has different regions, so I need to change them in appropriate time. What approach would be the best? One regionBootstrap with multiple regions? Or multiple RegionBootstraps?

Thank you

UPDATE: I add 4 regions to regionBootstrap and I am able to find entered region. After that, I remove those 4 regions and set 2 new regions, but device still finds one of the 4 regions set before. How is that possible?

Upvotes: 1

Views: 542

Answers (1)

davidgyoung
davidgyoung

Reputation: 64941

A few tips:

  • RegionBootstrap is designed to be one instance per application. Only use one, and only construct it once.

  • If you want to monitor multiple regions, you can use this constructor: RegionBootstrap(BootstrapNotifier application, List<Region> regions) e.g. new RegionBootstrap(this, regions);

  • If you want to change the regions being monitored by your RegionBootstrap after you have constructed one, don't make a new RegionBootstrap. Simply use:

    BeaconMananager beaconManager = BeaconManager.getInstanceForApplication(this); // Stop monitoring old region beaconManager.stopMonitoringBeaconsInRegion(oldRegion); // Start monitoring new region beaconManager.startMonitoringBeaconsInRegion(newRegion);

Upvotes: 2

Related Questions