Pregunta de entrevista de Trantor

Q. What is Activity Lifecycle?

Respuesta de la entrevista

Anónimo

14 dic 2024

The Activity Lifecycle in Android describes the states an Activity goes through from creation to destruction. Android manages these states to optimize app performance and user experience. 1.onCreate(): Called when the activity is created for the first time. Initialize resources, UI, and logic here. 2.onStart(): Called when the activity becomes visible to the user. 3.onResume(): Called when the activity starts interacting with the user (foreground state). 4.onPause(): Called when the activity is partially obscured (e.g., another activity appears). Save UI state here. 5.onStop(): Called when the activity is no longer visible. Release heavy resources. 6.onRestart(): Called before transitioning from stopped to started state. onDestroy(): Called before the activity is destroyed (e.g., back press or system killing). 7.onCreate(): Called when the activity is created for the first time. Initialize resources, UI, and logic here.