2.1 & 2.2 Activity Lifecycle Callbacks & State Transitions
An Activity is the fundamental UI component representing a single visual screen in Android. As users navigate, open other apps, receive phone calls, or rotate the screen, the Android OS transitions the Activity through 7 lifecycle callback methods:
onCreate(): Called when the activity is first instantiated. Initialize UI views (setContentView(R.layout.activity_main)), bind variables, and initialize databases.onStart(): Called when the activity becomes visible to the user, but not yet interactive.onResume(): Called when the activity enters the foreground and starts accepting user touch input. Activity is in Active / Running state.onPause(): Called when another activity comes into foreground (e.g., a dialog or split screen) and partially obscures this activity. Stop animations and release light resources.onStop(): Called when the activity is completely hidden from view. Save persistent draft data and release heavy resources.onRestart(): Called when an activity is navigated back to from the stopped state beforeonStart().onDestroy(): Called before the activity is permanently destroyed and reclaimed from memory (viafinish()or system killing).