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?
Android: onDestroy() or similar method in Application class
androidandroid-lifecycle
Related Topic
- Android – How to stop EditText from gaining focus at Activity startup in Android
- Android – How to pass data between Activities in Android application
- Android – unique Android device ID
- Android – ‘Context’ on Android
- Android – How to you get the build/version number of your Android application
- Android – Dialog throwing “Unable to add window — token null is not for an application” with getApplication() as context
- Java – Proper use cases for Android UserManager.isUserAGoat()
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.