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