How to get the intent that stops the service in android

前端 未结 2 1465
猫巷女王i
猫巷女王i 2021-01-18 10:23

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 ??

2条回答
  •  借酒劲吻你
    2021-01-18 10:49

    I understand this is an old question but, if anyone's looking for an alternative, you can register a BroadcastReceiver in your Service for stopping the service and then send broadcast to this receiver from all over your app. Here, you can get all the information from the intent sent to the receiver. Within the receiver, simply call stopSelf().

提交回复
热议问题