Question on Lifecycle Events on Android



What is the order that the lifecycle events are called after the device is rotated ?

onPause, onStop, onDestroy, onCreate, onStart, onResume


Rotating the device causes the Activity to be destroyed and recreated, so our lifecycle starts at onPause and ends at onResume. Note that we don't see onRestart, which only happens if the activity is stopped (but not destroyed) and then restarted.


More Info:
When we use onSaveInstanceState,

We're missing onStop and onDestroy, because those states happen after onSaveInstanceState is called . We at least see the lifecycle all the way through onSaveInstanceState and you'll see that the TextView gets filled with more logs as you rotate the device more.

Bu blogdaki popüler yayınlar

SDLC - Software Development Life Cycle

@SerializedName and @Expose annotations