I am trying to build an Enterprise App using ibeacons. I purchased Estimote Beacons Kit and trying to build an Android application to get the ID of each beacon, so that I can persist that ID into a Database and write my own business logic for the application.
Can any one help me out to range the beacons. I done with monitoring beacons and sending a Notification accordingly. Now I want only to range the Beacons and get the ID's. Please help with the code to get the beacon major and minor values so that I can kick start my app from there on-words.
You can use Estimote Android SDK for that. See quickstart which is beacon ranging:
private BeaconManager beaconManager = new BeaconManager(context);
// Should be invoked in #onCreate.
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
Log.d(TAG, "Ranged beacons: " + beacons);
}
});
// Should be invoked in #onStart.
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override public void onServiceReady() {
try {
beaconManager.startRanging(ALL_ESTIMOTE_BEACONS);
} catch (RemoteException e) {
Log.e(TAG, "Cannot start ranging", e);
}
}
});
// Should be invoked in #onStop.
try {
beaconManager.stopRanging(ALL_ESTIMOTE_BEACONS);
} catch (RemoteException e) {
Log.e(TAG, "Cannot stop but it does not matter now", e);
}
// When no longer needed. Should be invoked in #onDestroy.
beaconManager.disconnect();