Android Application: Activity Life Cycle

Android Application: Activity Life Cycle
Android Application: Activity Life Cycle
Every Living thing has as life cycle and so the Android Application is suppose to be having its life cycle too. Don't worry, I am not going to say that Android Applications are alive as Human Beings or Animals. But Yes, from the time and application comes alive in your phone to do the task they are built for, it go through a defined cycle and that is called as Android Activity Life Cycle.


An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.


Since Android is based on Java so the concept of classes will remain and we have the Activity base class, which defines a series of events that governs the life cycle of an activity.So while developing your Android applications you should keep in mind that Behind any window or form in the Android mobile application there is an Activity instance and to develop a mobile application with multiple windows you must create, for each display, a new class that extends Activity class. The Activity class defines the following events:   

onCreate()  : Called when the activity is first created and this is where you define the layout for the activity's user interface.


onStart()     :  Called when the activity becomes visible to the user. You can see it as a part of Visible Lifetime of an activity 


onResume()   Called when the activity starts interacting with the user and this is a good place to begin animations, open exclusive-access devices (such as the camera), etc.. 


onPause() -- Called when the current activity is being paused but has not been killed yet and the previous activity is being resumed.


onStop() -- Called when the activity is no longer visible to the user 


onDestroy() -- Called before the activity is destroyed by the system (either manually or by the system to conserve memory) and it will Perform any final cleanup before an activity is destroyed. 


onRestart() -- Called when the activity has been stopped and is restarting again 


Below is the whole Android Application cycle works like. It goes through the transitions that you define while developing your application and can take certain action under each kind of activity.



Learn and Have Fun. !! 

No comments: