How to detect IBeacon in android without using any library

后端 未结 2 608
别那么骄傲
别那么骄傲 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:01

    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.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题