I modified the OMGStop() method to something more like this:
public void cancelUpdates() {
//TODO potential bug here
if(pi == null)
setPendingIntent();
mgr.cancel(pi);
//Should one of these work?
stopService(new Intent(applicationContext, LocationPoller.class));
stopService(new Intent(applicationContext, LocationPollerService.class));
I’m storing pi (PendingIntent) as a member in my activity class. And this works fine to remove the PendingIntent from the AlarmManager.
However…
I would like to be able to stop the current location poll if there is one going on. Is it possible with your current design? I thought I could just stop the service, but the GPS continues to run.
Basically what i’m trying to do is stop everything when the user (me on my trip) changes a preference (such as the timeout, or USE GPS or update period. And then recreate everything with the new values.
Thanks,
Great code BTW – Exactly what I want for tracking my cross country journey 🙂
No, sorry. That’s theoretically possible to add, but probably a bit tricky, and definitely not there at the moment.
That is a perfectly reasonable concept, just not what
LocationPollersupports.LocationPollerwas designed more for the “check every hour” sorts of scenarios, where it is statistically unlikely that a check is going on while the user happens to be manipulating your app’s UI.