{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

FragmentManager.FragmentLifecycleCallbacks

{% setvar page_path %}androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html{% endsetvar %} {% setvar can_switch %}1{% endsetvar %} {% include "reference/_kotlin_switcher2.md" %}

abstract class FragmentManager.FragmentLifecycleCallbacks


Callback interface for listening to fragment state changes that happen within a given FragmentManager.

Summary

Public constructors

Public functions

Unit
onFragmentActivityCreated(
    fm: FragmentManager,
    f: Fragment,
    savedInstanceState: Bundle?
)

This function is deprecated.

To get a callback specifically when a Fragment activity's onCreate is called, register a androidx.lifecycle.LifecycleObserver on the Activity's Lifecycle in onFragmentAttached, removing it when it receives the Lifecycle.State#CREATED callback.

Unit
onFragmentAttached(fm: FragmentManager, f: Fragment, context: Context)

Called after the fragment has been attached to its host.

Unit
onFragmentCreated(
    fm: FragmentManager,
    f: Fragment,
    savedInstanceState: Bundle?
)

Called after the fragment has returned from the FragmentManager's call to Fragment#onCreate(Bundle).

Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onDestroy().

Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onDetach().

Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onPause().

Unit
onFragmentPreAttached(fm: FragmentManager, f: Fragment, context: Context)

Called right before the fragment's Fragment#onAttach(Context) method is called.

Unit
onFragmentPreCreated(
    fm: FragmentManager,
    f: Fragment,
    savedInstanceState: Bundle?
)

Called right before the fragment's Fragment#onCreate(Bundle) method is called.

Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onResume().

Unit
onFragmentSaveInstanceState(
    fm: FragmentManager,
    f: Fragment,
    outState: Bundle
)

Called after the fragment has returned from the FragmentManager's call to Fragment#onSaveInstanceState(Bundle).

Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onStart().

Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onStop().

Unit
onFragmentViewCreated(
    fm: FragmentManager,
    f: Fragment,
    v: View,
    savedInstanceState: Bundle?
)

Called after the fragment has returned a non-null view from the FragmentManager's request to Fragment#onCreateView(LayoutInflater, ViewGroup, Bundle).

Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onDestroyView().

Public constructors

FragmentLifecycleCallbacks

FragmentLifecycleCallbacks()

Public functions

onFragmentActivityCreated

fun onFragmentActivityCreated(
    fm: FragmentManager,
    f: Fragment,
    savedInstanceState: Bundle?
): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onActivityCreated(Bundle). This will only happen once for any given fragment instance, though the fragment may be attached and detached multiple times.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

savedInstanceState: Bundle?

Saved instance bundle from a previous instance

onFragmentAttached

fun onFragmentAttached(fm: FragmentManager, f: Fragment, context: Context): Unit

Called after the fragment has been attached to its host. Its host will have had onAttachFragment called before this call happens.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

context: Context

Context that the Fragment was attached to

onFragmentCreated

fun onFragmentCreated(
    fm: FragmentManager,
    f: Fragment,
    savedInstanceState: Bundle?
): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onCreate(Bundle). This will only happen once for any given fragment instance, though the fragment may be attached and detached multiple times.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

savedInstanceState: Bundle?

Saved instance bundle from a previous instance

onFragmentDestroyed

fun onFragmentDestroyed(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onDestroy().

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentDetached

fun onFragmentDetached(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onDetach().

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentPaused

fun onFragmentPaused(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onPause().

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentPreAttached

fun onFragmentPreAttached(fm: FragmentManager, f: Fragment, context: Context): Unit

Called right before the fragment's Fragment#onAttach(Context) method is called. This is a good time to inject any required dependencies or perform other configuration for the fragment before any of the fragment's lifecycle methods are invoked.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

context: Context

Context that the Fragment is being attached to

onFragmentPreCreated

fun onFragmentPreCreated(
    fm: FragmentManager,
    f: Fragment,
    savedInstanceState: Bundle?
): Unit

Called right before the fragment's Fragment#onCreate(Bundle) method is called. This is a good time to inject any required dependencies or perform other configuration for the fragment.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

savedInstanceState: Bundle?

Saved instance bundle from a previous instance

onFragmentResumed

fun onFragmentResumed(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onResume().

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentSaveInstanceState

fun onFragmentSaveInstanceState(
    fm: FragmentManager,
    f: Fragment,
    outState: Bundle
): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onSaveInstanceState(Bundle).

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

outState: Bundle

Saved state bundle for the fragment

onFragmentStarted

fun onFragmentStarted(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onStart().

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentStopped

fun onFragmentStopped(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onStop().

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentViewCreated

fun onFragmentViewCreated(
    fm: FragmentManager,
    f: Fragment,
    v: View,
    savedInstanceState: Bundle?
): Unit

Called after the fragment has returned a non-null view from the FragmentManager's request to Fragment#onCreateView(LayoutInflater, ViewGroup, Bundle).

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment that created and owns the view

v: View

View returned by the fragment

savedInstanceState: Bundle?

Saved instance bundle from a previous instance

onFragmentViewDestroyed

fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to Fragment#onDestroyView().

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state