5
I have a notification that appears when a service is running and disappears when it stops running.
If the user kills the application with the service running, the notification stays there forever.
Is there any way to know when the user killed the app so I can remove the notification? How can I catch this event?
Tried to use the
onDestroy()
?– Antony Alkmim
onDestroy()
is only in the activities, is not it? I can not use because they are destroyed at other times that the notification and the service must be alive.– Erick Filho
From what I’ve researched, there is
onDestroy
for Services also, http://developer.android.com/reference/android/app/Service.html#onDestroy()– Antony Alkmim
But I guess that way it won’t work for you.
– Antony Alkmim
Actually, I even implemented it here. But apparently it’s not being called when the user kills the app.
– Erick Filho
Poisé will not work because it identifies that the application was closed through the
onDestroy()
gives Activity. In this case, even if Activity closes the Service will still be running, so it does not run theonDestroy
of the service.– Antony Alkmim