i want to if the user press home button my service will be stop , this is my code but it\'s not working for me, please help me:
@Override
public boolean onKe
If you're trying to make sure the service only runs when the related activity is visible, a better solution would be to stop the service in the onPause() method of whatever activity the user is running. That way, the event is handled when the user presses "back" and when the user presses "home".
Likewise, you can bind your service to the activity (or activities). The bound service will be destroyed when all activities bound to it stop.