The Android Beacon Library's RangedBeacon.setSampleExpirationMilliseconds()
method has nothing to do with the frequency of the ranging updates. It is used to configure the time interval for averaging distance estimates. The RSSI (Received Signal Strength Indicator) is a measurement of how strong the signal is between the mobile device and the beacon, and is used as an input to estimate distance. Because this measurement is inherently volatile due to radio noise, a running average is used to smooth out this noise. By default, the interval of this running average is 20 seconds. Becasue this default may be inappropriate for applications that need less "lag" in the estimate of distance between the mobile device and the beacon, the library allows it to be configured to be a different period of time.
The default ranging refresh interval is controlled by different scanPeriod
and betweenScanPeriod
settings, which default to 1.1 seconds, and 0 seconds respectively. The defaults say that the library will scan for 1.1 seconds, then stop scanning for 0 seconds, then start scanning again. You can adjust these defaults by calls to beaconManager.setForegroundScanPeriod(long milliseconds)
and beaconManager.setForegroundBetweenScanPeriod(long milliseconds)
(there are also background equivalents to these methods for when you app is in the background, which default to 10 and 300 seconds, respectively.)
If you wish to conserve battery, then what you want to do is adjust the betweenScanPeriod
to be a longer value. But again, the library already adjust this to be 5 minutes when your app is in the background. You can read more information on this battery saver feature here.