Note that there are some explanatory texts on larger screens.

plurals
  1. POEfficient use of LocationManager in Android
    primarykey
    data
    text
    <p>I am trying to optimise an Android application which must achieve the following:</p> <ul> <li><p>Every hour, retrieve the GPS location and doSomeWork()</p></li> <li><p>At any other time if the device moves more than @MINIMUM_DISTANCE, increase update frequency to something like 5 minutes to log the movement, when movement ends we can return to the hourly updates.</p></li> </ul> <p>Now, AlarmManager firing every hour works a treat for the first requirement. It's a fine battery efficient method of accomplishing this task. However I'm unsure how to best accomplish the second requirement.</p> <p>Should I:</p> <ul> <li><p>Register an AlarmManager which fires every 5 minutes in tandem with the hourly timer? Register LocationManager each time and attempt to pull off a location, compare to previous location to determine whether movement has occurred.</p></li> <li><p>Register a LocationManager after my hourly wakeup with a minimum distance parameter equal to my required minimum movement.</p></li> <li><p>Something else?</p></li> </ul> <p>I can see pros and cons to each approach.</p> <p>Using the LocationManager minimum distance parameter seems to me to be the more concise solution but I'm concerned about battery drain, will this keep the GPS running hot the whole time regardless of whether my application is receiving updates? I am also not sure where the best place to register the receiver would be, I understand it's poor practice (not to mention nigh impossible) to keep a service running 100% of the time.</p> <p>Yes I am new to Android! About to go and test the behaviour of LocationManager.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload