Hi everyone,
I need to user de BeaconNotificationsManager with many beacons,
MyApplication.java
public void enableBeaconNotifications() {
if (beaconNotificationsEnabled) { return; }
BeaconNotificationsManager beaconNotificationsManager = new BeaconNotificationsManager(this);
BeaconNotificationsManager beaconNotificationsManager1 = new BeaconNotificationsManager(this);
BeaconNotificationsManager beaconNotificationsManager2 = new BeaconNotificationsManager(this);
beaconNotificationsManager.addNotification("80c66b4e5c439e272564bafd3664b103", "Hello, BEACON1.", "Goodbye, world.");
beaconNotificationsManager1.addNotification("9b69133b0ccc35a14784f9a564d5cc05", "Hello, BEACON2.", "Goodbye, world.");
beaconNotificationsManager2.addNotification("df6b6cb5be3d30438f683ad6638a2b18", "Hello, BEACON3.", "Goodbye, world.");
beaconNotificationsManager.startMonitoring();
beaconNotificationsManager1.startMonitoring();
beaconNotificationsManager2.startMonitoring();
beaconNotificationsEnabled = true;
}
BeaconNotificationManager.java
public BeaconNotificationsManager(final Context context) {
this.context = context;
beaconManager = new BeaconManager(context);
estimoteMonitoring = new EstimoteMonitoring();
estimoteMonitoring.setEstimoteMonitoringListener(new EstimoteMonitoringListener() {
@Override
public void onEnteredRegion() {
Log.d(TAG, "onEnteredRegion");
String message = enterMessages;
if (message != null) {
//llamamos al servicio para obtener las ofertas
URL_OFFER = URL_OFFER.replace(Constants.COD_BEACON, deviceIdBeacon);
URL_OFFER = URL_OFFER.replace(Constants.COD_PRODUCTO_FIDELIZACION, strTipoFidelizacion);
URL_OFFER = URL_OFFER.replace(Constants.COD_SEGMENTO_CLIENTE, strTipoSemento);
new GetOfferProduct().execute();
}
}
@Override
public void onExitedRegion() {
Log.d(TAG, "onExitedRegion");
}
});
beaconManager.setLocationListener(new BeaconManager.LocationListener() {
@Override
public void onLocationsFound(List<EstimoteLocation> locations) {
for (EstimoteLocation location : locations) {
if (location.id.toHexString().equals(deviceIdBeacon)) {
estimoteMonitoring.startEstimoteMonitoring(new EstimoteMonitoringPacket(location.id.toHexString(), location.rssi, location.txPower, location.channel, location.timestamp));
}
}
}
});
}
I want to send every notification beacon for my customer in background, and this way doesn’t work, thanks a lot!