Please explain the lifecycle of an Activity?

Sharad Jaiswal
Sharad Jaiswal

Posted On: Dec 24, 2020

 

Android is an open-source operating system that can be useful for many tasks. An android application will undergo various states that are associatively called as Android Activity Life Cycle.

The lifecycle of activity consists of 7 methods:-

  1. onCreate() - The function onCreate() is called When a user first opens an activity that acts the same as a constructor of a class. 
  2. onStart() - The function onStart() is called when an activity becomes visible to the user and is called after onCreate.
  3. onResume() - The function onResume() is called just before the user starts interacting with the application.
  4. onPause() - The function onPause() is called when the app is partially visible to the user on the mobile screen.
  5. onStop() - The function onStop() is called when the activity is no longer on the activity stack and not visible to the user.
  6. onRestart() - The function onRestart() is called when the activity in the stopped state is about to start again.
  7. onDestroy() - The function onDestroy() is  called when the activity is cleared from the application stack.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Android Interview Questions

    What is Android?

    Android is an open-sourced operating system by Linux that is primarily used in mobile devices like cell phones and tabl..

    Android Interview Questions

    What are the Android application components?

    Android application components are the building block essentially used in the Android application. The application mani..

    Android Interview Questions

    What does Fragment mean?

    A fragment means behavior or the portion of user interface in a Fragment Activity. One can combine multiple fragments i..