Situm is highly optimized to consume as less battery as possible: an app with Situm's default configuration may run for  for 9-12 hours before running out of battery (way more efficient than, for instance, the GPS). If this is not enough for you, Situm allows several configurations that will allow you to extend your battery life. This article provides a throurough explanation.



Battery Saver Mode


Situm consumption while the Battery Saver Mode is enabled is close to zero. If this mode is enabled, when the smartphone does not move (based on accelerometer data),  Situm stops reading & processing sensor data. Instead, Situm yields the last computed location as the current smartphone location. When the smartphone moves again, sensor reading & processing is restored. 


Battery Saver mode can be enabled by setting to true the LocationRequest.Builder().useBatterySaver method.


//Default: Batter Saver is disabled
LocationRequest locationRequest = new LocationRequest.Builder().build();

//Enable it to extend your battery life
LocationRequest locationRequest = new LocationRequest.Builder().useBatterySaver(true).build();



If you enable this mode in your application and output the computed location in your application logs, they might look like this.


//At first, new locations will be produced regullarly 
2021-02-10 19:55:43.065 onLocationChanged() called: location [36.1418, 10.1123] 
2021-02-10 19:55:44.064 onLocationChanged() called: location [36.2401, 11.2621]
...

//After a few minutes of inactivity, no new locations will be computed and the last one will be repeated
2021-02-10 19:58:28.235 onLocationChanged() called: location [36.9531, 10.5621] 
2021-02-10 19:58:29.497 onLocationChanged() called: location [36.9531, 10.5621] 
2021-02-10 19:58:30.211 onLocationChanged() called: location [36.9531, 10.5621] 
2021-02-10 19:58:31.217 onLocationChanged() called: location [36.9531, 10.5621] 
...

//If the smartphone moves, new locations will be computed inmediatelly
2021-02-10 19:59:12.064 onLocationChanged() called: location [36.4501, 10.1221]



Realtime panel updates (geolocation upload interval)  


By default, Situm computes one geolocation per second and sends it to the Situm cloud right away. This allows to monitor smartphone geolocation in real time, but if this feature is not required, you may save battery by spacing the uploads to the cloud.  You may also want to disable this feature completely: e.g. you may not want to store any of your user's geolocations in the Situm Cloud.


You may do this by using the LocationRequest.Builder().realtimeUpdateInterval. This parameter receives an enum object called LocationRequest.RealtimeUpdateInterval, that may have the following values.



Mode
Update IntervalApproximate* battery duration
REALTIMEEvery second9 to 12 hours
FASTEvery 5 seconds10 to 13 hours
NORMALEvery 15 seconds
12 to 15 hours
SLOWEvery 25 seconds14 to 16 hours
BATTERY_SAVEREvery 30 minutesUp to 24 hours
NEVERNever
Up to 24 hours

*Depends on device, ambient conditions, other applications running, etc.


On the inside, Situm SDK will continue to compute all the geolocations and will buffer them until the next upload to the cloud. This means that this method does reduce the number of geolocations that will finally be stored in Situm Cloud.



The following snippet shows some configurations that you may apply:


//Default (REALTIME): Upload locations to Situm Cloud every second.
LocationRequest locationRequest = new LocationRequest.Builder().build();
//This is equivalent to the default config
LocationRequest locationRequest = new LocationRequest.Builder().realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.REALTIME).build();


//NORMAL: Upload locations every 15 seconds
LocationRequest locationRequest = new LocationRequest.Builder().realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.NORMAL).build();

//NEVER: Never upload locations to Situm Cloud.
LocationRequest locationRequest = new LocationRequest.Builder().realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.NEVER).build();

When you apply any of these configurations, you may take a look at the RealTime panel in Situm Dashboard. If everything goes well, your users' geolocations should be updated at a different rate depending on the configuration you applied. As you can see in the following figure, with the REALTIME configuration most users geolocations will be updated every 1-3 seconds, while with the NORMAL configuration this may take up to 15-20 seconds. With the NEVER configuration, no user location will be received.





Compute Interval (Outdoor Positioning)


When the user is outdoors (outside a building configured with Situm technology), Situm SDK can provide his geolocation using the GPS and other smartphone sensors. The continuous use of the GPS might drain the smartphone battery, specially if Situm SDK computes them at a high frequency. Knowing this, Situm SDK allows you to space the time between consecutive GPS readings, which may help you to reduce significantly the battery consumption.  See more.