Get Intent passed to stopService(intent) in Servic

2019-09-20 18:08发布

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条回答
看我几分像从前
2楼-- · 2019-09-20 18:34

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().

查看更多
登录 后发表回答