Bluetooth Low Energy Android - Search in Background

限于喜欢 提交于 2019-12-10 10:47:54

问题


I would like to know whether it is possible to check in the background if someone enters or leaves the a beacon Region?

In iOS for example you can use the methods didEnterRegion or didExitRegion to send notifications from the background.

Is there any native possibility or has someone a workaround?


回答1:


Android doesn't have any "native" iBeacon capability at all, but you can see iBeacons using my company's open source Android iBeacon Library, which has APIs similar to those native to iOS 7.

In the case of iOS, the CLLocationManagerDelegate gives you access to the didEnterRegion and didExitRegion callbacks that you describe. In the Android iBeacon Library, the equivalent is the MonitorNotifier interface that gives you the same callback methods.

Making these callbacks successfully fire for apps that aren't in the foreground is a little tricky on both iOS and Android. On Android, you need to start a service of your own that runs when the Android device starts up, and bind to the IBeaconManager in that service.

Setting this up isn't super easy, so we developed a Pro Android iBeacon Library that does all this automatically. Examples are here.

EDIT: Both libraries above have been discontinued in favor of the free and open source Android Beacon Library which has all the feature of the pro library described above.



来源:https://stackoverflow.com/questions/19638118/bluetooth-low-energy-android-search-in-background

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