already depends on this (since v26.1.0) // Both AppCompatActivity & Support Fragment implement // LifecycleOwner interface. // Lifecycles only implementation "android.arch.lifecycle:runtime:$lifecycle_version" ... }
Adds a LifecycleObserver addObserver(@NonNull LifecycleObserver observer) // Removes the given observer from the observers list removeObserver(@NonNull LifecycleObserver observer) // Current state of the Lifecycle getCurrentState() // Compares the lifecycle states isAtLeast(@NonNull State state) ... }
Adds a LifecycleObserver addObserver(@NonNull LifecycleObserver observer) // Removes the given observer from the observers list removeObserver(@NonNull LifecycleObserver observer) // Current state of the Lifecycle getCurrentState() // Compares the lifecycle states isAtLeast(@NonNull State state) ... }
Adds a LifecycleObserver addObserver(@NonNull LifecycleObserver observer) // Removes the given observer from the observers list removeObserver(@NonNull LifecycleObserver observer) // Current state of the Lifecycle getCurrentState() // Compares the lifecycle states isAtLeast(@NonNull State state) ... }
protected void postValue(T value) {...} // Sets the value async ... @MainThread protected void setValue(T value) {...} // Sets the value sync ... protected void onActive() {...} // Has active observers i.e in Start/Resume state protected void onInactive() {...} }
protected void postValue(T value) {...} // Sets the value async ... @MainThread protected void setValue(T value) {...} // Sets the value sync ... protected void onActive() {...} // Has active observers i.e in Start/Resume state protected void onInactive() {...} // Has 0 active observers }
about lifecycle components d.android.com/topic/libraries/architecture/lifecycle Using ProcessLifecycleOwner for libraries example https://github.com/nisrulz/android-examples/tree/develop/UsingProcessLifecycleOwnerForLibs Using Lifecycle Components for libraries example https://github.com/nisrulz/android-examples/tree/develop/LifeCycleCompForLib