As a fledgling Android developer one of the first things you’ll need to do is get your head around Activity Classes. We can’t overstate the importance of this. A sharp, fluid understanding of how each class interacts with each other class, and the end result for end users will not only speed along your project dev time, but open up new possibilities for your programming. So let’s take a look at these in some detail.
onCreate(): This is called when the activity first starts up. You can use decompile apk it to perform one-time initialization such as launching the user interface. onCreate() utilizes one parameter that is either null or state information previously saved by the onSaveInstanceState( ) method, discussed below.
onFreeze(): Allows you to save your current state when one activity is being paused and another one resumes to interact with the user. After being paused, the system may at any time need to stop (or even outright kill) your application in order to claim resources for the current foreground activity. If this should happen, the state you supply here will later be recalled with onCreate(), when the user starts a new instance of your activity.
onPause(): This runs when the activity is about to go into the background, usually because another activity has been launched in front of it. This is where you should save your program’s persistent state, such as a database record being edited.
onDestroy(): This is called right before your activity is destroyed. If memory is tight, onDestroy( ) may never be called (the system may simply terminate your process). onSaveInstanceState(Bundle): Android calls this method to allow the activity to save per-instance states, such as a cursor position within a text field. Usually you won’t need to override it because the default implementation saves the state for user interface controls automatically.
onRestoreInstanceState(Bundle): This is called when the activity is being reinitialized from a state previously saved by the onSaveInstanceState() method. The default implementation restores the state of your user interface.