Using IntentService for Location listening but onDestroy called immediately after onHandleIntent

I am using an IntentService to listen for GPS location updates so it'll run when the user leaves the activity. The IS sends the Location in a message to the activity's handler.

The problem is, when the user hits the "stop tracking" button, the status bar notification saying "tracking..." is still there because it is created in the IntentService. Therefore I overrided onDestory() so I can call:

mNotificationManager.cancel(TRACKING);

But the problem is that when I implement onDestroy(), it is called immediately after onHandleIntent. If I delete my override onDestroy() code then it isn't called immediately and runs fine, sending locations back to the activity to be displayed on-screen.

Any ideas why onDestroy() is getting called immediately if I implement it but not if I dont?

I'm pretty confused here.

Thanks all,

Infinitifizz

6
задан Infiniti Fizz 7 May 2011 в 10:24
поделиться