0
4.7kviews
Explain Activity Life-cycle using neat Labelled diagram.

Mumbai University > Information Technology > Sem 5 > Open Source Technology

Marks: 5M

Year: Dec 2015

1 Answer
2
69views
  • Activity is an application component that allows user to perform an operation.
  • User performs various operation as making call, clicking photos, sending messages, viewing a map. For each operation an activity is created.
  • The main objective is to interact with users.
  • Activity plays crucial role as they are used to create a display for users.
  • Activity is composed of views that handles layout and provides text element, button, forms, graphics to device screen.

Creating Activity

  • We can create an activity by creating a java class that extends Activity class.

  • Each activity needs to create window for which user components are loaded. For this SetContentView() method is used.

  • Activities are displayed as full screen, but you can set different views such as floating by using WindowIsFloating or embedded by using ActivityGroupClass.

Startind an activity

  • Android API provides startActivity(Intent) method to start a new activity.

  • When new activity is invoked it is placed at the top of activity stack by pushing other activities.

  • StartActivity() method accepts single argument.

Life cucle of Activity

  • OnCreate() is called during creation of activity
  • OnStart() is called when user can visualize activity.
  • OnResume() is called when activity starts interaction with user.
  • OnPause() is called when user is not able to see the activity.
  • OnStop() is called when activity is not visible.
  • OnRestart is called when activity is stopped.
  • OnDestroy() is called to destroy activity.
Please log in to add an answer.