Android Jetpack架构之ProcessLifeCycleOwner

一、ProcessLifeCycleOwner是什么?

  用于监听App程序的生命周期。

二、示例

  ApplicationObserver类:

class ApplicationObserver: LifecycleObserver {

}

  DemoApplication类:

class DemoApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        ProcessLifecycleOwner.get().lifecycle.addObserver(ApplicationObserver())
    }

}

 

Android Jetpack架构之ProcessLifeCycleOwner

上一篇:android播放swf文件


下一篇:持久化之AOF(Append Only File)