I have an application that includes navigation. If the user starts navigation, a kind of "navigationLifecycleManager" is created. This is saved in the application instance so that it saves configuration changes, switches between acitivities, etc.
However, if the user "terminates" the application, I want to kill some background threads, store some minor data in the application store, and so on. So I need some kind of hook that will tell me when the application closes.
- Navigation must withstand any activity life cycle (therefore, the application instance doesnβt care)
- Navigation should be saved by pressing the home button.
- Navigation should not end by tapping back.
- Navigation should not be saved when it is killed, dragging it from the list of "recent applications".
You can definitely achieve this by overriding "onPause" and checking "isFinishing". But this does not solve the problem from the list of recent applications. Sweep seems to not cause anything. Neither "onPause", nor "onDestroy", nor "onTerminate" are called in the operation / application.
source share