How to get the intent that stops the service in android

前端 未结 2 1485
猫巷女王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:44

    AFAIK, this Intent is not delivered to the Service in any fashion.

    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.

提交回复
热议问题