Call Method When Program Exits - Ondestroy Not Reliable
I want to execute some functions when the program is exited by hitting the back button. This is now done by onDestroy() which works in every case but one. When coming back from ano
Solution 1:
Tactically, use onBackPressed()
.
Strategically, reconsider your architecture. A well-written activity should not care if onDestroy()
is called, as it is guaranteed to NOT always be called. For example, Android can terminate your process whenever it wants (e.g., extreme low memory conditions). The fact that you need onDestroy()
to work reliably suggests there are problems that should be resolved.
Post a Comment for "Call Method When Program Exits - Ondestroy Not Reliable"