Android: onDestroy() or similar method in Application class

androidandroid-lifecycle

I am extending Application class to work with some global variables that need context. I know there is onCreate() method in the Application class that gets called before any other onCreate() in activities, but I would like to know if there is onDestroy() or similar method in the Application class that could be overridden so that I would be able to store variables in persistent memory, unregister listener and send last message to server before app process gets killed? If not, is there any other way to do that?

Best Answer

There is no such call back on a production device for the Application class.

The things you want to do should usually be done right after the changes are made, or in the onPause() of the respective app component.