Search code examples
androidibeacon-androidaltbeacon

How to properly stop scanning beacon using android-beacon-library (altbeacon)


Im using android-beacon-library from altbeacon to scan in a foreground. I put

beaconManager.bind(this) on OnCreate

and put

beaconManager.unBind(this) on onDestroy()

, but when i check the logcat i saw

E/BeaconService: onDestroy()

i thought it stops scanning process but strangely it still receiving multiple of this : `

D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=D2:95:10:F1:2A:AF, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=null, mManufacturerSpecificData={76=[2, 21, -3, -91, 6, -109, -92, -30, 79, -79, -81, -49, -58, -21, 7, 100, 120, 37, 39, 27, 39, 27, -59]}, mServiceData={00005242-0000-1000-8000-00805f9b34fb=[65, 99, -46, -107, 16, -15, 42, -81]}, mTxPowerLevel=-2147483648, mDeviceName=neartalk], mRssi=-59, mTimestampNanos=120278331850532}`

My question is how to properly stop scanning beacon ???


Solution

  • I suspect this is a new bug introduced in the 2.10 version of the library. Starting with that version, scan cycle behavior was changed to not stop the scan at the end of the cycle on devices that support detecting multiple beacons per scan. This adds power savings and packet detections reliability benefits. But thinking about it now, I think it the change will cause exactly the symptoms you describe.

    If you have a chance, please verify that the problem goes away if you target version 2.9. if confirmed, I will open a bug report and make a fix.