Jez Higgins

Freelance software generalist
software created
extended or repaired


Older posts are available in the archive or through tags.

Feed

Follow me on Twitter
My code on GitHub

Contact
About

Friday 21 June 2013 The Forest Road Reader, No 74

Android LocationManager is, you be surprised to hear, the access into an Android device's location services - based on mobile phone cell, wifi snooping, or GPS. Using the GPS will give you really good, really accurate location data, and if you're moving pretty spot-on estimates of your speed and bearing. However, using the GPS can chew through your batteries pretty quickly. The API documentation says
Choosing a sensible value for minTime is important to conserve battery life. Each location update requires power from GPS, WIFI, Cell and other radios. Select a minTime value as high as possible while still providing a reasonable user experience ... The minDistance parameter can also be used to control the frequency of location updates. If it is greater than 0 then the location provider will only send your application an update when the location has changed by at least minDistance meters, AND at least minTime milliseconds have passed. However it is more difficult for location providers to save power using the minDistance parameter, so minTime should be the primary tool to conserving battery life.

Hmm, helpful. Ish. Select a minTime value as high possible while still providing a reasonably user experience. To plug an unentirely unrandom example, if you're trying to provide live directions to someone riding their bike, a reasonable user experience involves telling them that a turn is coming up so the can properly prepare, and then when to turn. For a right turn, you'd probably want to know about 50 metres or so beforehand.

A gentle cycling pace is around 12mph - even a child can maintain that kind of speend, so you'd probably find that a little slow. 12mph, just toddling along. Let's go metric, it makes the sums easier - 12mph is, give or take, 20km/h. 20km/h is 333 and one third metres per minute, which is 5½m/s. Five and a half metres per second. 15mph is 6.7m/s and once you're turning 20mph you're approaching 10m/s.

If you want to give notice of a turn, then 10 metres could be the difference between the upcoming notice being comfortable and a bit of a rush. You could miss the turn itself entirely. So, updates need to be, what? At least every half a second, I reckon. I'll give it a spin.

Of course, you don't need frequent updates if you're along way from the next turn. Perhaps I could get a bit adaptive. You don't want to burn a whole load of battery for no benefit if the next turn is a mile or more away.

It's the summer solstice. I cut the grass.


Tagged android


Jez Higgins

Freelance software generalist
software created
extended or repaired

Older posts are available in the archive or through tags.

Feed

Follow me on Twitter
My code on GitHub

Contact
About