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

changmangke 2012-01-14 03:29:25
也就是说如果Activity A启动了服务S,现在需要在Activity B中终止服务S,请问应该怎么做?非常感谢各位的解答
...全文
336 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
android_baiyuchuan 2012-01-18
  • 打赏
  • 举报
回复

service 也是可以设置action的
intent.setaction(String..);
stopService(intent);
正解
淘淘大师 2012-01-18
  • 打赏
  • 举报
回复
1、获取服务:Intent
2、停止:stopService(intent);
CyberLogix 2012-01-18
  • 打赏
  • 举报
回复
stopService(intent);
wyx100 2012-01-18
  • 打赏
  • 举报
回复
无论在那个Activity里都可以停止当前的服务 Intent intent = new Intent(当前Activity.this,
GPSBackservice.class);
stopService(intent);
追风筝的孩子 2012-01-18
  • 打赏
  • 举报
回复
楼上正解
a-white-lie 2012-01-18
  • 打赏
  • 举报
回复
无论在那个Activity里都可以停止当前的服务 Intent intent = new Intent(当前Activity.this,
GPSBackservice.class);
stopService(intent);
a-white-lie 2012-01-18
  • 打赏
  • 举报
回复
Intent intent = new Intent(JobStatusUpdate.this,
GPSBackservice.class);
stopService(intent);
changmangke 2012-01-14
  • 打赏
  • 举报
回复
具体应该怎么做呢?能提供相关的代码给我参考一下吗?
lovebayberry 2012-01-14
  • 打赏
  • 举报
回复
增加一个静态类,服务对象S定义其中,在哪里都可操作S了。

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧