当前位置:编程学习 > wap >>

请问在Activity中如何终止由另一个Activity启动的服务?

也就是说如果Activity A启动了服务S,现在需要在Activity B中终止服务S,请问应该怎么做?非常感谢各位的解答 --------------------编程问答-------------------- 增加一个静态类,服务对象S定义其中,在哪里都可操作S了。 --------------------编程问答-------------------- 具体应该怎么做呢?能提供相关的代码给我参考一下吗? --------------------编程问答-------------------- Intent intent = new Intent(JobStatusUpdate.this,
GPSBackservice.class);
stopService(intent); --------------------编程问答-------------------- 无论在那个Activity里都可以停止当前的服务 Intent intent = new Intent(当前Activity.this,
GPSBackservice.class);
stopService(intent); --------------------编程问答-------------------- 楼上正解 --------------------编程问答-------------------- 无论在那个Activity里都可以停止当前的服务 Intent intent = new Intent(当前Activity.this,
GPSBackservice.class);
stopService(intent); --------------------编程问答-------------------- stopService(intent); --------------------编程问答-------------------- 1、获取服务:Intent
2、停止:stopService(intent); --------------------编程问答--------------------
service 也是可以设置action的
intent.setaction(String..);
stopService(intent);
正解
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,