Skip to content

Instantly share code, notes, and snippets.

@burhanrashid52
Last active November 14, 2017 16:30
Show Gist options
  • Save burhanrashid52/9b6ff837f2cef043abe619326360f215 to your computer and use it in GitHub Desktop.
Save burhanrashid52/9b6ff837f2cef043abe619326360f215 to your computer and use it in GitHub Desktop.
/**
* Created by Burhanuddin on 11/12/2017.
*/
public class MyLifeCycleObserver implements LifecycleObserver {
public static final String TAG = MyLifeCycleObserver.class.getSimpleName();
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
public void create() {
//This method is called AFTER LifcycleOwner(Activity/Fragment) onCreate() is called
Log.e(TAG, "onCreate: ");
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void start() {
//This method is called AFTER LifcycleOwner(Activity/Fragment) onStart() is called
Log.e(TAG, "onStart: ");
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void resume() {
//This method is called AFTER LifcycleOwner(Activity/Fragment) onResume() is called
Log.e(TAG, "onResume: ");
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
public void pause() {
//This method is called BEFORE LifcycleOwner(Activity/Fragment) onPause() is called
Log.e(TAG, "onPause: ");
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void stop() {
//This method is called BEFORE LifcycleOwner(Activity/Fragment) onStop() is called
Log.e(TAG, "onStop: ");
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void destroy() {
//This method is called BEFORE LifcycleOwner(Activity/Fragment) onDestroy() is called
Log.e(TAG, "onDestroy: ");
}
@OnLifecycleEvent(Lifecycle.Event.ON_ANY)
public void any() {
//This method is called on any Lifcycle changes happens
Log.e(TAG, "onAny: ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment