Situm is highly optimized to consume as less battery as possible: an app with Situm’s default configuration may run 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.
Battery Saver Mode (Android only) #
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. The following figure shows a graphical explanation of this mode.
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 (Android) or the SITLocationRequest.realtimeUpdateInterval (iOS). This parameter receives an enum object called LocationRequest.RealtimeUpdateInterval (Android) or SITRealtimeUpdateInterval (iOS) , that may have the following values.
|Mode||Update Interval||Approximate* battery duration|
|REALTIME||Every second||9 to 12 hours|
|FAST||Every 5 seconds||10 to 13 hours|
|NORMAL||Every 15 seconds||12 to 15 hours|
|SLOW||Every 25 seconds||14 to 16 hours|
|BATTERY_SAVER||Every 30 minutes||Up to 24 hours|
|NEVER||Never||Up to 24 hours|
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 Android snippet shows some configurations that you may apply (iOS usage is similar):
//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.
If you like to integrate battery saver mode on iOS devices there is one issue though. As the app get into background mode, sooner or later the operating system will stop running the app. This means some timers may not work until the app is in foreground again for the entire interval.
It can be fixed by applying for location background modes as described Apple Developer Documentation. This way the operating system won’t stop your app even if it gets to background mode and Situm SDK will work the same in both platforms, uploading all locations at a regular pace.
Outdoor Positioning compute interval #
If your application is computing outdoor geolocations (using the GPS), another way to reduce the battery consumption is to modify the outdoor compute interval, the frequency with which outdoor locations are computed. The following table illustrates approximate battery savings based on this parameter.
|Compute Interval||Estimated* battery life|