I have an application that involves navigation.
If the user starts a navigation, a kind of "navigationLifecycleManager" is created. This is stored in the application instance so that it survives configuration changes, switching between acitivities etc..
However if the user "quits" the application, I want to kill some background threads, store some minor data into the application storage and so on. So i need some hook(s) that tell me when the app quits.
You can't handle swipe, because system just removes your process from memory without calling any callback.
I have checked, that before user calls "recent apps" screen,
onPause() will be always called. So you need to save all data in
onPause method without checking
To check back button, use onBackPressed method.