开发者

Service stopping another Service

开发者 https://www.devze.com 2022-12-20 06:50 出处:网络
i have a question about Services in Android. I have a application with two Services A and B. Is it开发者_如何学C possible that Service A can stop Service B?

i have a question about Services in Android. I have a application with two Services A and B. Is it开发者_如何学C 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?


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));
0

精彩评论

暂无评论...
验证码 换一张
取 消