在application 调用registerActivityLifecycleCallbacks()方法
//下面就是对应的生命周期
每个回调都有一个activity,这个activity就是当前的activity
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks(){
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
})
网友评论