I'm writing an application where real-time knowledge of the GPS state
is critical to convey to the user. I request GPS updates at 1000 ms
intervals -- when I haven't received another update 1500 ms past the
most recent update, I want to display a yellow icon, and 5000 ms after
the most recent update I want to display a red icon. Currently, I'm
doing it like this:
private CountDownTimer gpstimeout;
public void onLocationChanged(Location location) {
if (gpstimeout != null) gpstimeout.cancel();
gpstimeout = new CountDownTimer(5000, 1500) {
public void onTick(long m) { setYellow(); }
public void onFinish() { setRed(); }
};
gpstimeout.start();
}
This works well (except that onTick appears to be called immediately
on creation of the new CountDownTimer), but it seems like creating and
destroying a new thread every second wouldn't be the best way to do
things. Is there a better approach to this?
Thanks,
Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---