Application.ActivityLifecycleCallbacks 理解

ActivityLifecycleCallbacks是什么?

Application通过此接口提供了一套回调方法,用于让开发者对Activity的生命周期事件进行集中处理。


1.继承Application

public class BaseApplication extends Application

在AndroidManifest里起用自定义Application

2.重写Application的onCreate()方法,或在Application的无参构造方法内,调用Application.registerActivityLifecycleCallbacks()方法,并实现ActivityLifecycleCallbacks接口


3.Activity生命周期类完成


onActivityCreated

onActivityStarted

onActivityResumed

onActivityPaused

onActivityStopped

onActivitySaveInstanceState

onActivityDestroyed

你可能感兴趣的:(Application.ActivityLifecycleCallbacks 理解)