Android - Activity Lifecycle


What is Activity?
Android Activity is just like Java Applets, any screen you see in an android app is rendered by an Activity. Every Android Application must have at least one Activity.

Launcher Activity: 
Activity that launches or start with application start-up is called launcher Activity.


What is callback method?
A callback method is some special method called by the android OS to notify the current state of application i.e. whether it is running or not, whether it is watching by user or not.

Activity Lifecycle methods:
Android activity uses the following methods along its lifecycle:

  • onCreate()
  • onStart()
  • onResume()
  • onPause()
  • onStop()
  • onDestroy()
When an user launches an application

  • onCreate() is called
  • then onStart()
  • and then onResume()

On back button press (when you launch another app or go to home)

  • onPause()
  • then onStop()
Now if you again open this application

  • onRestart()
  • onStart()
  • onResume()

Actually after calling onResume() android application becomes visible to user. After performing the above operation and printing/logging on each callback method, we got the following output from an application:
















Comments

  1. Thank you so much for sharing this information.This post helped me in Understanding Lifecycle in Android Activity .
    keep up the good work by sharing such blogs in future.This blog was really helpful.

    ReplyDelete

Post a Comment