Reputation: 1279
My new "app in progress" uses an instance of CLLocationManager for several purposes. To make the app as battery-friendly as possible, the location services should be activated only if needed, and deactivated immediately when the data refresh is done. For my purpose it's perfectly enough to fetch the location data only once in 10 seconds. (Haven't yet decided the exact interval length).
My question is, which is the most battery-efficient method of "turning off the Location services"? Is it sufficient to just use the "stopUpdatingLocation" method and keep the CLLocationManager himself in memory, or am I required to release the entire instance, and allocate a new one before the next refresh?
Upvotes: 5
Views: 4121
Reputation: 1786
I agree with the other answers that stopUpdatingLocation
in combination with the distanceFilter
and desiredAccuracy
is the way to go. Note that when the desired accuracy is in the scope of kilometres, the location manager might not even have to fire up the GPS.
Similarly, depending on what you use it for, have a look at region monitoring and significant location updates since those are more battery friendly.
Related: Location Awareness Programming Guide - Tips for Conserving Battery Power
Upvotes: 6
Reputation: 56625
Setting appropriate distanceFilter
and desiredAccuracy
are probably the two factors that have the most impact on you battery life.
To really know what is the most battery-friendly you should use Instruments and measure the battery drain on the device. There is a built-in tool for that.
Upvotes: 1
Reputation: 6139
Yes. Calling stopUpdatingLocation
is enough.
Better way is to set good values for distanceFilter
and desiredAccuracy
. 10secs is not enough time to warm up the gps.
Upvotes: 2