public void setBackgroundMode ( boolean backgroundMode ) { if ( ! isBleAvailableOrSimulated ( ) ) { LogManager . w ( TAG , "Method invocation will be ignored." ) ; return ; } mBackgroundModeUninitialized = false ; if ( backgroundMode != mBackgroundMode ) { mBackgroundMode = backgroundMode ; try { this . updateScanPeriods ( ) ; } catch ( RemoteException e ) { LogManager . e ( TAG , "Cannot contact service to set scan periods" ) ; } } }
This method notifies the beacon service that the application is either moving to background mode or foreground mode . When in background mode BluetoothLE scans to look for beacons are executed less frequently in order to save battery life . The specific scan rates for background and foreground operation are set by the defaults below but may be customized . When ranging in the background the time between updates will be much less frequent than in the foreground . Updates will come every time interval equal to the sum total of the BackgroundScanPeriod and the BackgroundBetweenScanPeriod .