2

Does CLLocationManager distanceFilter do anything to save energy?

 3 years ago
source link: https://www.codesd.com/item/does-cllocationmanager-distancefilter-do-anything-to-save-energy.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Does CLLocationManager distanceFilter do anything to save energy?

advertisements

Does the CLLocationManager distanceFilter property do anything to conserve battery life / power usage between making its request at the required distance. I don't think it does, but I just wanted to check that I should still be calling stopUpdatingLocation and not just leaving it running.

I found one answer on here that suggested the phone dialled down its polling (until the desired distance was reached) thus saving power. But on the other hand it seems to hint that even checking the desired distance needs the antennas to be active and as such saves little power.

Currently when I need a locations details I am explicitly doing startUpdatingLocation, checking for a suitable location before sending the stopUpdatingLocation message to the CLLocationManager.


There is nothing directly documented (on the distanceFilter property) to indicate that this is the case. You should definitely be calling stopUpdatingLocation if you care about battery life and giving the user a decent experience. In my own experience developing apps I've never seen any improvement in battery life when using larger values for the distanceFilter - perhaps if it does do anything the gains are just too small to notice.

I believe the point of distanceFilter is not to conserve power, but to allow you to control the number of callbacks you get should your app not require constant streams of location data.

That said, I suspect it does get involved with power requirements. Certainly its related property distanceAccuracy has a definite impact on power management - as per the Apple docs:

Setting the desired accuracy for location events to one kilometer gives the location manager the flexibility to turn off GPS hardware and rely solely on the WiFi or cell radios. This can lead to significant power savings.

So I would personally suspect that distanceFilter and distanceAccuracy both affect power in some way. The problem (for you, I guess) is that the measurable effects will vary from device to device, and probably from OS version to OS version. So it's very difficult to quantify in any meaningful way.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK