Based on your comment:
The problem is that the service is not called from the activity that i want to close. I have activity A that calls Activity B that calls service S, and i want S to close A.
this is the wrong approach. The better thing to do would be to have Activity A register a broadcast receiver that listens for a particular Intent
. When the service wants A to finish, it can broadcast a specific Intent
. In this way, your service is communicating implicitly with the activity without having to have a reference to it, or know if it is running.