Search code examples
androidbluetooth-lowenergyandroid-bluetoothaltbeaconandroid-ibeacon

Parsing the URL of a beacon


I am using android.bluetooth.le api to scan bluetooth LE devices around me

 @Override
            public void onLeScan(final BluetoothDevice device, final int rssi,
                                 byte[] scanRecord) { ... }

and i'm using this callback method to notify me if some results are found. Now the problem is this, that i am unable to find the method which will give the url which a beacon will transmitting.

Note : i am trying to do it with android.bluetooth.le, but if you've something else in your mind or any 3rd party api that could do this job, i will be happy to listen to you.

Thanks in advance.


Solution

  • There are lots of kinds of Bluetooth LE beacons, but the main ones made today that transmit a URL are beacons sending the Eddystone-URL format.

    You can use the open source Android Beacon Library to scan and parse that format. See the Working With Eddystone-URL section here

    The library will do the scanning for you, but if you want to keep using android.bluetooth.le package directly, you can simply use the Android Beacon Library components that parse the beacon. See the docs for the BeaconParser class.

    Oh, and this library is open source so feel free to copy and change the code!