Search code examples
ibeaconibeacon-android

How to get the proximity


I'm having some iBeacons around here.

Now how do I know that they are far or near?

Is there a way to get that from a beacon?

I've seen this https://estimote.github.io/Android-SDK/JavaDocs/ but I don't get it how to get from a beacon that it is far or not?


Solution

  • When using the open source Android iBeacon Library, this is a very simple process:

        @Override 
        public void didRangeBeaconsInRegion(Collection<IBeacon> iBeacons, Region region) {
            for (IBeacon iBeacon: iBeacons) {
                if (iBeacon.getProximity() == IBeacon.PROXIMITY_NEAR) {
                    Log.d(TAG, "The beacon is near");
                }
                else if (iBeacon.getProximity() == IBeacon.PROXIMITY_FAR) {
                    Log.d(TAG, "The beacon is far");
                }            
            }
        }
    

    You can see a larger example of this in the Ranging Sample Code here.