Tuesday 19 February 2013

Activity In Android

Android Activity LifeCycle
As we provided the just intro about the main components of android, now we'll discuss these components in details. First component we discuss is ACTIVITY.

As we all know that activity is used to display the user interface just like in AWT or SWING in java. Interface is made in XML(eXtensible Markup Language).
Activity is an class provided by the android framework . which provide the facility to display the layout to the user. This class provide some callback methods to represent the different change of state of an activity.
To define an activity, we have to create a subclass of Activity Class and need to override its methods.
Different change of state of an activity are as follows:-

  1. Active State
  2. Visible State
  3. Inactive / Invisible State
     1Active State:-   An activity is in active state only when it has user focus and it is visible to user to handle       the life-cycle of the activity. 
Life-cycle of an active activity can be managed by onPause() and onResume() callback methods.

     2. Visible State:- An activity is in visible state when it appears to the user but doesn't have user focus.
Life-cycle of an visible activity can be manged by onStart() and onStop() callback methods.

     3. Inactive/Invisible State:- An activity is in Inactive/Invisible state when it doesn't have user focus and also doesn't appear to the user.
Life-cycle of an inactive state can be managed by onCreate() and onDistroy() callback methods.

0 comments:

Post a Comment