onEnteredRegion only receives a Beacons list always with one beacon

Hi guys,
Trying to get some signal strenght values so i did a small app to motorize my beacons signal.
I’m using IBeacon protocoll and it’s API.

When onEnteredRegion triggers, it seems that only prints the first beacon that finds… And i have all with a short distance from me.

I already debbug it and yeah, only one beacon on List beacons

Here’s a code that i’m using:

beaconManager.setMonitoringListener(new BeaconManager.BeaconMonitoringListener() {
            @Override
            public void onEnteredRegion(BeaconRegion region, List<Beacon> beacons) {

                String s="";
                int counter=0;
                for (Beacon intersectedBeacon : beacons)
                {
                    counter++;
                    s += String.valueOf(counter) + " -- Major: "+ String.valueOf(intersectedBeacon.getMajor()) + "|Minor: "  + String.valueOf(intersectedBeacon.getMinor()) + "|MeasuredPower: "  + intersectedBeacon.getMeasuredPower() + " dbm|Rssi: " + intersectedBeacon.getRssi() +"\n\n **";

                }
                textView.setText(s);
                Toast.makeText(MainActivity.this,"Beacon intersectado!" ,Toast.LENGTH_LONG).show();

            }
            @Override
            public void onExitedRegion(BeaconRegion region) {
                Toast.makeText(MainActivity.this,"Left the region!!!",Toast.LENGTH_SHORT).show();
            }
        });

Some help please? Thanks!

This is how monitoring API works. It returns you only those beacons that triggered onEnter event. In most cases it only one beacon (JavaDoc).
If you want to get all beacons that are around you need to use ranging:

beaconManager.setRangingListener(new BeaconManager.RangingListener() {
    @Override
    public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
       
    }
});

Note: BeaconManager is now deprecated for ranging and monitoring. Please switch to Proximity SDK:
https://github.com/estimote/android-proximity-sdk

1 Like