Using Lifecycle in AppCompatActivity

suggest change

Extend your activity from this activity

public abstract class BaseCompatLifecycleActivity extends AppCompatActivity implements LifecycleRegistryOwner {
    // We need this class, because LifecycleActivity extends FragmentActivity not AppCompatActivity

    private final LifecycleRegistry lifecycleRegistry = new LifecycleRegistry(this);

    public LifecycleRegistry getLifecycle() {
        return lifecycleRegistry;

Feedback about page:

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

Table Of Contents