Custom Lifecycle-aware component

suggest change

Each UI component lifecycle changed as shown at image. You may create component, that will be notified on lifecycle state change:

public class MyLocationListener implements LifecycleObserver {
    private boolean enabled = false;
    private Lifecycle lifecycle;
    public MyLocationListener(Context context, Lifecycle lifecycle, Callback callback) {

    void start() {
        if (enabled) {
           // connect

    public void enable() {
        enabled = true;
        if (lifecycle.getState().isAtLeast(STARTED)) {
            // connect if not connected

    void stop() {
        // disconnect if connected

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents