Harold
Harold

Reputation: 927

Service stopping another Service

i have a question about Services in Android. I have a application with two Services A and B. Is it possible that Service A can stop Service B? I dont want to do it through a Activity, cause the Application will be in Background. If some special Event happen in Service A, then it should tell Service B to stop. How can i do that?

Upvotes: 1

Views: 1708

Answers (1)

Nikola Smiljanić
Nikola Smiljanić

Reputation: 26873

You may need some other way to obtain an object of SeriviceA but this is the basic idea. Services are Contexts just like Activities are.

stopService(new Intent(ServiceA.this, ServiceB.class));

Upvotes: 7

Related Questions