FragmentManager.FragmentLifecycleCallbacks


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 CREATED callback.

Unit

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 onCreate.

Unit

Called after the fragment has returned from the FragmentManager's call to onDestroy.

Unit

Called after the fragment has returned from the FragmentManager's call to onDetach.

Unit

Called after the fragment has returned from the FragmentManager's call to onPause.

Unit

Called right before the fragment's onAttach method is called.

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

Called right before the fragment's onCreate method is called.

Unit

Called after the fragment has returned from the FragmentManager's call to onResume.

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

Called after the fragment has returned from the FragmentManager's call to onSaveInstanceState.

Unit

Called after the fragment has returned from the FragmentManager's call to onStart.

Unit

Called after the fragment has returned from the FragmentManager's call to 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 onCreateView.

Unit

Called after the fragment has returned from the FragmentManager's call to onDestroyView.

Public constructors

FragmentLifecycleCallbacks

Added in 1.1.0
FragmentLifecycleCallbacks()

Public functions

onFragmentActivityCreated

Added in 1.1.0
Deprecated in 1.3.0
fun onFragmentActivityCreated(
    fm: FragmentManager,
    f: Fragment,
    savedInstanceState: Bundle?
): Unit

Called after the fragment has returned from the FragmentManager's call to onActivityCreated. 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

Added in 1.1.0
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

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

Called after the fragment has returned from the FragmentManager's call to onCreate. 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

Added in 1.1.0
fun onFragmentDestroyed(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to onDestroy.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentDetached

Added in 1.1.0
fun onFragmentDetached(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to onDetach.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentPaused

Added in 1.1.0
fun onFragmentPaused(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to onPause.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentPreAttached

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

Called right before the fragment's onAttach 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

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

Called right before the fragment's onCreate 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

Added in 1.1.0
fun onFragmentResumed(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to onResume.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentSaveInstanceState

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

Called after the fragment has returned from the FragmentManager's call to onSaveInstanceState.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

outState: Bundle

Saved state bundle for the fragment

onFragmentStarted

Added in 1.1.0
fun onFragmentStarted(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to onStart.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentStopped

Added in 1.1.0
fun onFragmentStopped(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to onStop.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state

onFragmentViewCreated

Added in 1.1.0
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 onCreateView.

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

Added in 1.1.0
fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment): Unit

Called after the fragment has returned from the FragmentManager's call to onDestroyView.

Parameters
fm: FragmentManager

Host FragmentManager

f: Fragment

Fragment changing state