Take the 2-minute tour ×

I have a service running in the background of an activity, now when the user presses the home button, onPause is called for the activity, what i want is to stop the service running in the background when onPause is called, but then i get an Error and a Force Close, Any ideas? Thank you!

share|improve this question
What's that error? –  steveoh May 6 '12 at 17:39
If your binding to the service, you'll get a nullpointer when you haven't connected. So check your binding for null before you attempt to stop it. –  Blundell May 6 '12 at 18:25

1 Answer 1

Since we don't have any piece of code, I'm guessing the problem is you didn't recreate the intent that started the service before trying to stop it.

For example if you start the service this way:

Intent serviceIntent = new Intent(this, myService.class);

You can stop it like this:

Intent serviceIntent = new Intent(this, myService.class);

Hope to have guessed well

share|improve this answer

Your Answer


