Activity LifeCycle Flashcards
what is an activity lifecycle
Different states an activity goes through
onCreate
onStart
onResume
When activity is lauched, its the first method getting called. Its like a constructor of a class When user can see the screen, onStart is called When screen is ready to interact with the user, then its onResume
These 3 methods get called so quickly that as a end user you dont come to know
onPause
onStop
onDestroy
onPause - when part of app is visible but in background
onStop - when activity is not visible to user
onDestroy - when activity is killed
when we minimize - onPause and onStop is called
onRestart
when we go back to the activity
usecase 1
when we start 2nd activity from 1st activity following is the sequence of calls a1 - onPause a2 - onCreate a2 - onStart a2- onResume a1- onStop
usecase2
when we move back to A1 A2 onPause A1 onRestart A1 onStart A1 onResume A2 onStop A2 onDestroy
usecase3
screenlock
onPause
onStop
usecase4
when screen lock is opened
onRestart
onStart
onResume
usecase5
pressing the home button
onPause
onStop
usecase 6
when resuming the activity
onRestart
onStart
onResume
usecase 7
killing app
onPause
onStop
onDestroy
usecase 8
Setting Permissions