https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.State.html
STARTED Lifecycle.State STARTED For an Activity, this state is reached in two cases: after onStart call; right before onPause call.
As the above documentation says, I couldn't understand the rationale behind the STARTED state right before onPause call. Can someone please explain that?
Notice that the values in the Lifecycle.State
enum
do not include a PAUSED
state. There are only five states: CREATED, DESTROYED, INITIALIZED, RESUMED, STARTED
. These do not exactly correspond with the normal Activity lifecycle that we all know and love:
Also note the following from the Lifecycle class documentation:
ON_CREATE, ON_START, ON_RESUME events in this class are dispatched after the LifecycleOwner's related method returns. ON_PAUSE, ON_STOP, ON_DESTROY events in this class are dispatched before the LifecycleOwner's related method is called
The execution of the onPause()
is the closing boundary for the RESUMED
state. At this point, the Activity is no longer considered RESUMED
and it is certainly not DESTROYED
. Since we don't have a PAUSED
state it follows it must now be in the STARTED
state. This is technically true, the Activity hasn't yet stopped but it is no longer resumed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With