Lifecycle原理分析

2020-06-23  本文已影响0人  dashingqi
Android_Banner.jpg

简介

Lifecycle解决什么问题?

原理分析

getLifecycle()
  public class ComponentActivity extends androidx.core.app.ComponentActivity implements
       LifecycleOwner,
       ViewModelStoreOwner,
       SavedStateRegistryOwner,
       OnBackPressedDispatcherOwner {

public interface LifecycleOwner {
   /**
    * Returns the Lifecycle of the provider.
    *
    * @return The lifecycle of the provider.
    */
   @NonNull
   Lifecycle getLifecycle();
}

addObserver()方法

调用的addObserver()是属于LifyCycleRegistry中的,我们先来看下LifyCycleRegistry这个类

总结
上一篇下一篇

猜你喜欢

热点阅读