I have 3 Estimote Beacons (Div Kit). In my Android app I’m trying to change 3 TextViews to show each beacon’s major and minor. I’ve changed the beacons settings to advertise signal every 1ms which is the shortest period of time.
The problem is that my BeaconManager object is detecting only one beacon and it takes a while to do that.
App.java
public class App extends Application {
public static BeaconManager mBeaconManager;
@Override
public void onCreate() {
super.onCreate();
mBeaconManager = new BeaconManager(getApplicationContext());
mBeaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(1), 0);
mBeaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
mBeaconManager.startMonitoring(new Region(
"monitored region",
UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"),
null, null));
}
});
}
}
That’s because you use beacon monitoring for only a single region—the “all beacons with the default Estimote UUID region”. This means that when your Android devices “hears” the first beacon that matches (i.e., one of your three), it’ll report an “enter” event with that one.
If you want to make sure you get the majors/minors of all three beacons, either (a) monitor for each of them separately (i.e., 3 regions, defined by UUID+major+minor of each beacon—but then you already need to know the majors/minors upfront, so I guess need to scan for them ), or (b) use ranging instead.
I’ve done as you told me but the main problem still occur. The beacons are not directly discovered or not at all!
I tried to copy the same code as in the Proximity Content for Multiple Beacons template in cloud but it is not even getting called…
proximityContentManager.setListener(new ProximityContentManager.Listener() {
@Override
public void onContentChanged(Object content) {
String text;
Integer backgroundColor;
if (content != null) {
EstimoteCloudBeaconDetails beaconDetails = (EstimoteCloudBeaconDetails) content;
text = "You're in " + beaconDetails.getBeaconName() + "'s range!";
backgroundColor = BACKGROUND_COLORS.get(beaconDetails.getBeaconColor());
myMethod(beaconDetails);
} else {
text = "No beacons in range.";
backgroundColor = null;
}
Responsiveness is another topic. Ranging is more responsive, as it keeps scanning for beacons all the time. Monitoring is meant to be energy-efficient (to conserve the smartphone’s battery), so that it’s okay to use even if the app is in the background. But that comes at the expense of responsiveness.