Bluetooth Low Energy Android - Search in Backgroun

2019-05-28 12:46发布

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条回答
Deceive 欺骗
2楼-- · 2019-05-28 13:30

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.

查看更多
登录 后发表回答