同时它们还是实现了 LifecycleOwner 接口,里面的 getLifecycle() 就是返回这个 mLifecycleRegistry 用的。
Posted liyanyan665
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了同时它们还是实现了 LifecycleOwner 接口,里面的 getLifecycle() 就是返回这个 mLifecycleRegistry 用的。相关的知识,希望对你有一定的参考价值。
SupportActivity.java(用于support库)
------------------------------
public class SupportActivity extends Activity implements LifecycleOwner
private LifecycleRegistry mLifecycleRegistry = new LifecycleRegistry(this);
ComponentActivity.java(用于androidx库)
------------------------------
public class ComponentActivity extends Activity
implements LifecycleOwner, KeyEventDispatcher.Component
private LifecycleRegistry mLifecycleRegistry = new LifecycleRegistry(this);
Fragment.java
------------------------------
public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener, LifecycleOwner
LifecycleRegistry mLifecycleRegistry = new LifecycleRegistry(this);
LifecycleOwner.java
------------------------------
public interface LifecycleOwner
@NonNull
Lifecycle getLifecycle();
————————————————
以上是关于同时它们还是实现了 LifecycleOwner 接口,里面的 getLifecycle() 就是返回这个 mLifecycleRegistry 用的。的主要内容,如果未能解决你的问题,请参考以下文章
无法访问“com.ex.app.MainActivity”的超类型“android.arch.lifecycle.LifecycleOwner”