Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guaranteed alternative to onDestroy()?

I'm trying to execute some code whenever my activity is killed, but not when it's simply moved to the background (so just calling it in onPause() isn't a solution), and I understand onDestory() is not guaranteed to be called. I've been searching all over and haven't found a way to do this. How can I go about tackling this problem? Is it possible?

like image 689
Drazen Bjelovuk Avatar asked Dec 25 '22 08:12

Drazen Bjelovuk


1 Answers

Nothing. You can never be guarantied to be called when an app ends, because it can always be terminated abnormally- it could crash, the battery could be pulled out, etc. onDestroy is the closest you can come. But you should never write a program that requires cleanup at termination time.

like image 147
Gabe Sechan Avatar answered Dec 29 '22 01:12

Gabe Sechan