I'm trying to set up a quick and dirty GPS lookup via LocationManager which fetches a network location (within 500 meters) every half second for ten seconds. In other words, I'm just trying to find the correct coarse Criteria settings and the correct logic to stop checking after 10 seconds of no better locations within my Handler thread.
I'm thinking my main loop should look something like this:
/**
* Iteration step time.
*/
private static final int ITERATION_TIMEOUT_STEP = 500; //half-sec intervals
public void run(){
boolean stop = false;
counts++;
if(DEBUG){
Log.d(TAG, "counts=" + counts);
}
//if timeout (10 secs) exceeded, stop tying
if(counts > 20){
stop = true;
}
//location from my listener
if(bestLocation != null){
//remove all network and handler callbacks
} else {
if(!stop){
handler.postDelayed(this, ITERATION_TIMEOUT_STEP);
} else {
//remove callbacks
}
}
}
What I want to know is after I fetch the last known location as my initial best location and kick off my thread, how do I set up the coarse criteria so that I receive a more accurate one than the initial one (in order to compare the two for freshness), which is usually diametrically different from my current location?