Looking at the Activity Life Cycle diagram, I notice that onPause()
and onStop()
can both lead to the "process" being killed. This would require onCreate()
to be called when the user wants to resume their application. The point being that onStop()
is not necessarily called, nor is onDestroy()
, but that onPause()
may be the only event that the Activity may see. This being the case, onPause()
must handle saving the application status so that the user can return back to it later, regardless of whether onStop()
is called or not.
I can see onDestroy()
being used to clean up Activity specific resources that would naturally be eliminated in a process kill action. Is there anything else that onDestroy()
would be good for?
And what would onStop()
be good for? Why would I want to override it for?
If I got your question right: It depends what you want to do with your application. Let's say you are programming application that uses GPS. In the onStop()
which is called when the activity is no longer visible to the user, you can remove these requests. Or you can stop the some service if your application is running any. Or you can save preferences (not recommended, do it in onPause()
instead), or you can close permanent connection to a server.....If I think of anything else, I'll add more...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With