Skip to content

Instantly share code, notes, and snippets.

@pokk
Created December 7, 2016 08:31
Show Gist options
  • Save pokk/1af6cdc426d025f05ac79bb69c450ee4 to your computer and use it in GitHub Desktop.
Save pokk/1af6cdc426d025f05ac79bb69c450ee4 to your computer and use it in GitHub Desktop.
Activity and Fragment lifecycle.

Introduction

Activity

Activity life cycle normally

onCreate ->
onStart ->
onResume -> ...

After we roate the device screen, the life cycle will continue as below...

onSaveInstanceState –>
onPause –>
onStop –>
onDestroy –>
onCreate –>
onStart –>
onRestoreInstanceState –>
onResume –> ...

Then we rotate again...

onSaveInstanceState –>
onPause –>
onStop –>
onDestroy –>
onCreate –>
onStart –>
onRestoreInstanceState –>
onResume –>
onSaveInstanceState –>
onPause –>
onStop –>
onDestroy –>
onCreate –>
onStart –>
onRestoreInstanceState –>
onResume –>

Fragment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment