Monitor the life cycle of Activity,FragmentActivity,Fragment,v4.app.Fragment
传入Activity,FragmentActivity的上下文,Fragment 或者 v4.app.Fragment的引用,就可以方便的监听它们的生命周期
- Monitor the life cycle of Activity,FragmentActivity,Fragment,v4.app.Fragment
<dependency>
<groupId>com.joybar.lifecycle</groupId>
<artifactId>lifecyclelistener</artifactId>
<version>1.0.7</version>
<type>pom</type>
</dependency>
compile 'com.joybar.lifecycle:lifecyclelistener:1.0.7'
LifecycleManager lifecycleManager = new LifecycleManager();
lifecycleManager.registerLifecycleListener(context, new LifecycleListener() {
@Override
public void onStart() {
Log.d(TAG, fragmentTagName+"_"+"onStart");
}
@Override
public void onResume() {
Log.d(TAG, fragmentTagName+"_"+"onResume");
}
@Override
public void onPause() {
Log.d(TAG, fragmentTagName+"_"+"onPause");
}
@Override
public void onStop() {
Log.d(TAG, fragmentTagName+"_"+"onStop");
}
@Override
public void onDestroy() {
Log.d(TAG, fragmentTagName+"_"+"onDestroy");
}
});
Copyright 2017 MyJoybar
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.