Getting Beacon information at runtime


#1

Hii
I’m working on an Android project involving Estimote Proximity Beacons, when a user gets in range of a beacon, it displays the locations’s deatial in relation to the beacon.
I already have database, in which I store the location details and with the Beacon’s ID (UID,Major,Minor) as it’s primary key. I don’t intend to use Estimote cloud but at the same time I need to get the Beacon’s information (UID,Minor,Major) at runtime, so my problem is that when I try to fetch the UID, major or minor from the Beacon class it gives me the default data.
I’m using Beacon Monotring. In the listener, onEnteredRegion I use the objects provided from the beacons discovered list (List beacons).
Code :

@Override
    public void onCreate() {
        super.onCreate();

        listeners = new ArrayList<>();
        beaconManager = new BeaconManager(getApplicationContext());
        beaconManager.setBackgroundScanPeriod(500,500);
        beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
            @Override
            public void onServiceReady() {
                beaconManager.startMonitoring(new BeaconRegion(
                        "monitored region",
                        null,
                        null, null));
            }
        });

        beaconManager.setMonitoringListener(new BeaconManager.BeaconMonitoringListener() {
            @Override
            public void onEnteredRegion(BeaconRegion region, List<Beacon> beacons) {
                Log.i("event enter", "entered");
                for (BeaconListener ltnr : listeners)
                    ltnr.onBeaconEvent(beacons.get(0));
            }
            @Override
            public void onExitedRegion(BeaconRegion region) {
                // could add an "exit" notification too if you want (-:

                Log.i("exit becon", region.getProximityUUID().toString());
            }
        });

    }

#2

What do you mean by default data? UUID, major and minor of each Beacon are null?
It seems that you are using region that will match any beacons around. It may lead to behavior where you will receive onEnter immediatly with first beacon found, but almost never onExit unless you get far away from any iBeacon. If you want to get a list of beacons around you should use ranging.