Combine iBeacon bluetooth low energy with Android 4.3

rekire picture rekire · Jul 26, 2013 · Viewed 20.7k times · Source

I'm looking for a way to detect iBeacon (iOS 7.0 feature) from an Android device. I read the Android documentation, where it seem that the iBeacon is some kind of GATT server which sends its position. While the Android documentation says that I should not poll that data, but for the detection this would be nessesary.

I google a lot but this topic is quite new (I even created a new tag ) so I would be happy if I get some links to ressources from the iOS world which descripes the implementation. Also if there are some Android libs which I did not find yet would be nice.

Answer

davidgyoung picture davidgyoung · Sep 26, 2013

EDIT: The library below has been moved here:

https://github.com/AltBeacon/android-beacon-library


I have ported the iOS7 iBeacon SDKs to Android, and was able to see standard iBeacons and estimate their range. The code is available here:

https://github.com/RadiusNetworks/android-ibeacon-service

For this to work, you need Android 4.3 which introduced the Low Energy Bluetooth APIs. You also need a device with a low energy bluetooth chipset.

If you don't want to use the full library above, you can roll your own. iBeacons simply transmit a BLE advertisement once per second that start with a known sequence of bytes. You simply have to tell Android to do a BLE scan, get each advertisement, and look for one that starts with the known iBeacon byte sequence. You can then parse out the iBeacon fields. Here is the code the shows how this is done:

https://github.com/RadiusNetworks/android-ibeacon-service/blob/master/src/com/radiusnetworks/ibeacon/IBeacon.java#L177-L231