CLLocationmanager: save battery

My new “application” uses an instance of CLLocationManager for several purposes. To make the application as convenient as possible for use in batteries, location services should be activated only when necessary and immediately deactivated when updating data. For my purposes, this is quite enough to get location data only once every 10 seconds. (Not yet determined the exact length of the interval).

My question is, is this the most efficient battery for "disabling location services"? Is it enough to just use the stopUpdatingLocation method and keep the CLLocationManager in memory, or do I need to free the entire instance and assign a new one until the next update?

+4
source share
3 answers

I agree with other answers that stopUpdatingLocation combined with distanceFilter and desiredAccuracy is the way to go. Note that when the desired accuracy is within kilometers, the location manager may not even have to start GPS.

Similarly, depending on what you are using it for, look at the monitoring of the region and significant location updates, as they are more battery friendly.

Regarding: Location Programming Guide - Battery Conservation Tips

+6
source

Yes. Calling stopUpdatingLocation enough.

It is best to set good values ​​for distanceFilter and desiredAccuracy . 10 seconds is not enough to warm up gps.

CLLocationManager

+2
source

Setting the appropriate distanceFilter and desiredAccuracy is probably the two factors that most affect your battery life.

However

To really know what is most convenient for the battery, you should use the Tools and measure the battery drain on the device. There is a built-in tool for this.

+1
source

Source: https://habr.com/ru/post/1410966/


All Articles