Hi,
I’m doing an app to change the background color of the Activitys, according to the beacon who was discovered. I created a Region for each Beacon, with his minor’s and major’s numbers.
I wonder if there’s a way to do this without using a lot of BeaconManagers.
beaconManager1.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(0), 0);
beaconManager2.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(0), 0);
beaconManager3.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(0), 0);
beaconManager1.setMonitoringListener(new BeaconManager.MonitoringListener() {
@Override
public void onEnteredRegion(Region region, List<Beacon> beacons) {
activity_main.setBackgroundColor(Color.parseColor("#08F0E0"));
txBeaconMint.setText(flavor + ice);
Log.d(TAG, "Inside of Region 1");
}
@Override
public void onExitedRegion(Region region) {
Log.d(TAG, "Out of Region 1");
}
});
beaconManager2.setMonitoringListener(new BeaconManager.MonitoringListener() {
@Override
public void onEnteredRegion(Region region, List<Beacon> beacons) {
activity_main.setBackgroundColor(Color.parseColor("#A2F008"));
txBeaconMint.setText(flavor + mint);
Log.d(TAG, "Inside of Region 2");
}
@Override
public void onExitedRegion(Region region) {
Log.d(TAG, "Out of Region 2");
}
});
beaconManager3.setMonitoringListener(new BeaconManager.MonitoringListener() {
@Override
public void onEnteredRegion(Region region, List<Beacon> beacons) {
activity_main.setBackgroundColor(Color.parseColor("#9708F0"));
txBeaconMint.setText(flavor+blueberry);
Log.d(TAG, "Inside of Region 3");
}
@Override
public void onExitedRegion(Region region) {
Log.d(TAG, "Out of Region 3");
}
});