Android LifecycleRegistry: setCurrentState vs handleLifecycleEevent

May 13, 2019

As per the source code of LifecycleRegistry.java, they are the same (as both called moveToState).

public void setCurrentState(@NonNull State state) {
    moveToState(state);
}

NOTE: setCurrentState is more direct, using Lifecycle.State

public void handleLifecycleEvent(@NonNull Lifecycle.Event event) {
    State next = getStateAfter(event);
    moveToState(next);
}

NOTE: handleLifecycleEvent translate Lifecycle.Event to Lifecycle.State.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.