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 ??
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
I understand this is an old question but, if anyone's looking for an alternative, you can register a
BroadcastReceiver
in yourService
for stopping the service and then send broadcast to thisreceiver
from all over your app. Here, you can get all the information from theintent
sent to thereceiver
. Within thereceiver
, simply callstopSelf()
.AFAIK, this
Intent
is not delivered to theService
in any fashion.Instead of
stopService()
, you can usestartService()
to pass your extras, and include something in there that causes your service to callstopSelf()
. This will have the net effect of callingstopService()
and supplying extra data at the same time.