How to detect IBeacon in android without using any library

后端 未结 2 616
别那么骄傲
别那么骄傲 2021-02-01 10:37

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

2条回答
  •  长发绾君心
    2021-02-01 11:19

    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

提交回复
热议问题