In Android, How to get ibeacon details onExitedRegion when Region is created with proximity UUID only

孤街浪徒 提交于 2019-12-13 05:47:09

问题


I am working on android application with Estimote beacons. I am trying to work on a scenario where i will be using more than 100 beacons. For this, instead of creating separate Region for each beacon, I am creating single Region by assigning common Proximity UUID for all beacons and declaring Region by passing Proximity UUID only. I am keeping Major and Minor for uniquely identifying the beacons.

Since my application has to be in background, I am using BeaconManager.MonitoringListener interface with onEnteredRegion and onExitedRegion callbacks(My understanding is Ranging can only be done when application is in foreground). Since, onExitedRegion does not provide me any List of beacons that triggered onExitedRegion, how can I get beacon details, like Major, Minor in onExitedRegion?


回答1:


EDIT: The library mentioned below has been replaced by the Android Beacon Library. Code samples are available on the same site.


You do not say what library you are using, but the open source Android iBeacon Library allows you to do this by combining ranging and monitoring. The library has no restriction on using ranging in the background (unlike iOS). The library is fully compatible with any standard iBeacon.

Although the library's didExitRegion callback does not tell you the specific beacon that disappeared, you can keep track of these visible beacons based on the list passed to you in the most recent didRangeBeaconsInRegion callback. That way, when you get the didExitRegion callback, you know which beacons were last visible before they all disappeared.

Samples of both ranging and monitoring code are available here.




回答2:


In Estimote SDK MonitoringListener has method onEnteredRegion(Region region, List<Beacon> beacons). Where beacons is a list of beacons that triggered onEnteredRegion event. This list may not reflect all beacons around that are matching given region.

In order to have more precise list of beacons you need to start ranging in onEnteredRegion callback.



来源:https://stackoverflow.com/questions/23935137/in-android-how-to-get-ibeacon-details-onexitedregion-when-region-is-created-wit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!