Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect IBeacon in android without using any library

i am new to Ibeacon and i want to know can we detect Ibeacon in android without using any SDKLibrary or library can any one give sample example.

i know some library like Radius Networks. but i don't want to use any library

like image 850
Likhit Jagatiya Avatar asked May 08 '14 15:05

Likhit Jagatiya


2 Answers

The Android OS does not have any code that detects iBeacons, but it does have code that allows you to scan for Bluetooth LE devices, which are a lower-level device than an iBeacon.

You can roll-your own code that detects iBeacons using this Bluetooth LE scanning. That's exactly what the Android iBeacon Library from Radius Networks does. It is open source, so if you don't want to use the library, you can simply copy blocks of code out of the library and do your own detection.

The source code is here: https://github.com/RadiusNetworks/android-ibeacon-service

EDIT: the library has been moved to http://github.com/AltBeacon/android-beacon-library

If you detection use cases are very simple, this might work fine. Be careful not to bite off too much work, though, because handling all the edge cases can become increasingly complex. That's certainly what I learned when writing the library.

If you just want to play with this, I would focus on one class from the library: IBeacon.java

This class can convert from an Android Blueooth LE scan record to an IBeacon (if the scanned Bluetooth device is indeed an iBeacon)

You can read about how to set up Bluetooth LE scanning on Android here: http://developer.android.com/guide/topics/connectivity/bluetooth-le.html

like image 71
davidgyoung Avatar answered Sep 20 '22 13:09

davidgyoung


There is a new small library: https://github.com/inthepocket/ibeacon-scanner-android

Without a library it's very easy to scan for ibeacons, you just need to create the correct ScanFilter, based on the iBeacon, and then start a BLE scan. Creating the correct ScanFilter can be hard at first, best have a look at the code in the mentioned library.

Dependant on Android version, location needs to be turned on, location permission needs to be granted and bluetooth, always, needs to be on.

like image 38
Elias Avatar answered Sep 18 '22 13:09

Elias