OnNearablesDiscovered returns empty list?

Hi,

As I understand it, the “OnNearablesDiscovered()” method should be triggered only when a nearable is in range.

The problem is, within this method, the first thing I do is print out the size of the list Log.e("Nearables", String.valueOf(nearables.size()));

sometimes this returns 0! Shouldn’t this never occur? What is going on here…i.e. why is it triggering regularly regardless if beacons are nearby or not?

as an FYI I changed my scanning periods like so:

beaconManager.setBackgroundScanPeriod(200, 0);
beaconManager.setForegroundScanPeriod(200, 0);

and adjusted my advertising frequency to 1000ms (still) and 500ms (stationary).

Also, strangely, sometimes my app will show that 0 nearables are nearby even when there are 3 literally 5 inches from the phone. It will say this for multiple scans (10-20 seconds of scanning a tthe frequency above)

Yeah, the “onNearablesDiscovered” name is a bit misleading … the method is in fact called in regular intervals (specified by the “setForegroundScanPeriod”), and when nothing is nearby, it simply returns an empty list.

As for why your app sometimes “loses” the stickers for a good while … could be maybe that the Bluetooth stack is crashing? Can you add “setErrorListener” to your code, and see if it throws anything? What Android device are you testing with?