如何获得在Android中停止服务的意图 [英] How to get the intent that stops the service in android
本文介绍了如何获得在Android中停止服务的意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用stopService()
停止服务.我想发送额外的数据.如何在服务中检索这些额外数据?
I am using stopService()
to stop the service . and I want to send Extra data with the intent . how to retrieve this extra data in the service ??
推荐答案
AFAIK,此Intent
不会以任何方式传递给Service
.
AFAIK, this Intent
is not delivered to the Service
in any fashion.
您可以使用startService()
而不是stopService()
来传递附加信息,并在其中包含一些使您的服务调用stopSelf()
的内容.这将产生如下效果:调用stopService()
并同时提供额外的数据.
Instead of stopService()
, you can use startService()
to pass your extras, and include something in there that causes your service to call stopSelf()
. This will have the net effect of calling stopService()
and supplying extra data at the same time.
这篇关于如何获得在Android中停止服务的意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文