Get Intent passed to stopService(intent) in Service

人走茶凉 提交于 2019-12-25 18:33:58

问题


I have a requirement to detect source of destroying service. I am using intent and extra while calling

stopService(intent).

But where to catch this intent in Service class to act upon. Already gone through android docs, nothing helpful found. Any help is highly appreciated.


回答1:


Now, I believe Mark Murphy when he said it isn't possible. As 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().



来源:https://stackoverflow.com/questions/39191968/get-intent-passed-to-stopserviceintent-in-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!