0

I am modifying the Demo App provided by Estimote. At the moment I am receiving a notification when I enter in the region of a beacon and then I won't receive any more notification unless I exit that region. I would like instead to receive a notification each time the closest beacon is changed. That is if the closest beacon is the green then I would like to receive a notification, but if after 2 seconds the closest beacon is the blue one I would like to get another notification. Then I will filter the notification in some way..

I have a class called NotifyApp which extends an Application. I don't undersant if I have to use different MonitoringListener methods, one for each region or instead should I use the RangingListener..

 public void onCreate() {
   super.onCreate();
   notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
   beaconManager = new BeaconManager(this);

   beaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(1), 0);

   for (int i=0; i<3; i++) {
     region = new Region("rid", null, null, MyBeacons.getInstance().getMinor(i));

     beaconManager.setMonitoringListener(new MonitoringListener() { 
       @Override
       public void onEnteredRegion(Region region, List<Beacon> beacons) {
         postNotification("MONITORING: Beacon " + MyBeacons.getInstance().getColor(beacons.get(0).getMinor()));
       }
       @Override
       public void onExitedRegion(Region region) {
         postNotification("Exited region");
       }
     });
  } 
}
ayasha
  • 1,221
  • 5
  • 27
  • 46

1 Answers1

1

Monitoring API is only for discovering entering and exiting regions.

From your use case it looks like you want to use ranging API. You should use it just after you had discovered beacons with monitoring.

Wiktor Gworek
  • 486
  • 3
  • 7
  • hey wikor, how can we start using using rangeListener after discovering beacons with monitory? do we do call setRangingListener inside our onEnteredRegion function in setMonitoringListener? – ueg1990 Sep 27 '14 at 23:12