【发布时间】:2012-12-30 09:50:00
【问题描述】:
我想知道服务是否从特定活动中终止,因此我在调用 stopServivce(service) 时从该活动中传递了一个字符串。
代码如下:
Intent service = new Intent(Activity.this,
service.class);
service.putExtra("terminate", "activity terminated service");
stopService(service);
但我似乎可以在 onDestroy() 方法中使用 getIntent().getExtras().getString("terminate); 访问此变量。
[编辑]
我找到了绕过这个障碍的方法,但我希望我的问题仍能得到解答。我只是在活动中的onDestroy() 方法中完成了我必须做的任何事情,然后调用了stopService(service)。我很幸运,我的情况不需要更复杂的事情。
【问题讨论】:
标签: android android-intent service