Skip to content

Instantly share code, notes, and snippets.

@vilmarbfilho
Created February 1, 2016 11:50
Show Gist options
  • Save vilmarbfilho/b9d73b52a5236188c2f9 to your computer and use it in GitHub Desktop.
Save vilmarbfilho/b9d73b52a5236188c2f9 to your computer and use it in GitHub Desktop.
Life cycle fragment android
public class BaseFragment extends Fragment{
private static final String TAG = "base_fragment";
@Override
public void onAttach(Context context) {
super.onAttach(context);
Log.i(TAG, "onAttach()");
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate()");
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.i(TAG, "onCreateView()");
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Log.i(TAG, "onActivityCreated()");
}
@Override
public void onStart() {
super.onStart();
Log.i(TAG, "onStart()");
}
@Override
public void onResume() {
super.onResume();
Log.i(TAG, "onResume()");
}
@Override
public void onPause() {
super.onPause();
Log.i(TAG, "onPause()");
}
@Override
public void onStop() {
super.onStop();
Log.i(TAG, "onStop()");
}
@Override
public void onDestroyView() {
super.onDestroyView();
Log.i(TAG, "onDestroyView()");
}
@Override
public void onDestroy() {
super.onDestroy();
Log.i(TAG, "onDestroy()");
}
@Override
public void onDetach() {
super.onDetach();
Log.i(TAG, "onDetach()");
}
}
@vilmarbfilho
Copy link
Author

Life cycle fragment Android

Image of lifecycle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment