I have an IntentSerivce
that runs in the background sometimes and it can be quite a long running process in certain instances. I give an option for the user to quit the application which basically just stops and polling and ignores any GCM
push notifications. But if a push notification came in and the IntentService
is taking a while to finish doing what it has to (gets information from a server and sends a notification to the user if needed, like a new message arrived or something).
Here is the problem, if the user elects to "Quit" the app while the intentservice
is still running they will still get the notification which I do not want. I know that there is the stopSelf()
method for the service but I need to stop it in an activity when I know the user "Quit" the application via a menu button. Sending another intent
to the service does not work since the intents get queued up and calling context.stopService(intent);
in my activity does not work either so how else can I stop it?