AltBeacon / android-beacon-library

Allows Android apps to interact with BLE beacons
Apache License 2.0
2.84k stars 836 forks source link

3.0: Callback for entering and exiting of one proximity zone #257

Open egmontr opened 9 years ago

egmontr commented 9 years ago

Remember the entering and exiting of one proximity zone (range) and report it to the app.

davidgyoung commented 9 years ago

I agree this would be a useful enhancement. There are two challenges in coming up with a good implementation.

The problem is that the estimated distance fluctuates, so if the mobile device is near the boundary, it would cause repeated entry/exit events. One possibility is to have a "threshold" parameter, which defaults to a value that is 100% of the proximity distance. So it might work like this:

 ProximityFilter proximityFilter = new ProximityFilter(5, 10);  // 5 meter distance filter with a 10 meter exit filter.  Same as calling new ProximityFilter(5);
 region.setProximityFilter(proximityFilter);

Monitoring on the region above would only trigger an entry when the estimated distance is < 5 meters, and an exit would then only trigger if the distance > 10 meters.