Google is committed to advancing racial equity for Black communities. See how.

FragmentController

open class FragmentController
kotlin.Any
   ↳ androidx.fragment.app.FragmentController

Provides integration points with a FragmentManager for a fragment host.

It is the responsibility of the host to take care of the Fragment's lifecycle. The methods provided by FragmentController are for that purpose.

Summary

Public methods
open Unit
attachHost(@Nullable parent: Fragment?)

Attaches the host to the FragmentManager for this controller.

open static FragmentController
createController(@NonNull callbacks: FragmentHostCallback<*>)

Returns a FragmentController.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the activity created state.

open Unit

Lets all Fragments managed by the controller's FragmentManager know a configuration change occurred.

open Boolean

Sends a context item selection event to the Fragments managed by the controller's FragmentManager.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the create state.

open Boolean
dispatchCreateOptionsMenu(@NonNull menu: Menu, @NonNull inflater: MenuInflater)

Lets all Fragments managed by the controller's FragmentManager know they should create an options menu.

open Unit

Moves Fragments managed by the controller's FragmentManager into the destroy state.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the destroy view state.

open Unit

Lets all Fragments managed by the controller's FragmentManager know the device is in a low memory condition.

open Unit

Lets all Fragments managed by the controller's FragmentManager know the multi-window mode of the activity changed.

open Boolean

Sends an option item selection event to the Fragments managed by the controller's FragmentManager.

open Unit

Lets all Fragments managed by the controller's FragmentManager know their options menu has closed.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the pause state.

open Unit
dispatchPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)

Lets all Fragments managed by the controller's FragmentManager know the picture-in-picture mode of the activity changed.

open Boolean

Lets all Fragments managed by the controller's FragmentManager know they should prepare their options menu for display.

open Unit

open Unit

Moves all Fragments managed by the controller's FragmentManager into the resume state.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the start state.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the stop state.

open Unit

Destroys the loaders and, if their state is not being retained, removes them.

open Unit

Retains the state of each of the loaders.

open Unit

Starts the loaders.

open Unit

Stops the loaders, optionally retaining their state.

open Unit
dumpLoaders(@NonNull prefix: String, @Nullable fd: FileDescriptor?, @NonNull writer: PrintWriter, @Nullable args: Array<String!>?)

Dumps the current state of the loaders.

open Boolean

Execute any pending actions for the Fragments managed by the controller's FragmentManager.

open Fragment?
findFragmentByWho(@NonNull who: String)

Returns a fragment with the given identifier.

open MutableList<Fragment!>

Returns the list of active fragments.

open Int

Returns the number of active fragments.

open FragmentManager

Returns a FragmentManager for this controller.

open LoaderManager!

Returns a LoaderManager.

open Unit

Marks the fragment state as unsaved.

open View?
onCreateView(@Nullable parent: View?, @NonNull name: String, @NonNull context: Context, @NonNull attrs: AttributeSet)

Instantiates a Fragment's view.

open Unit

Lets the loaders know the host is ready to receive notifications.

open Unit
restoreAllState(@Nullable state: Parcelable?, @Nullable nonConfigList: MutableList<Fragment!>?)

Restores the saved state for all Fragments.

open Unit
restoreAllState(@Nullable state: Parcelable?, @Nullable nonConfig: FragmentManagerNonConfig?)

Restores the saved state for all Fragments.

open Unit

Restores the saved state for all LoaderManagers.

open Unit
restoreSaveState(@Nullable state: Parcelable?)

Restores the saved state for all Fragments.

open SimpleArrayMap<String!, LoaderManager!>?

Returns a list of LoaderManagers that have opted to retain their instance across configuration changes.

open FragmentManagerNonConfig?

Returns a nested tree of Fragments that have opted to retain their instance across configuration changes.

open MutableList<Fragment!>?

Returns a list of Fragments that have opted to retain their instance across configuration changes.

open Parcelable?

Saves the state for all Fragments.

Public methods

attachHost

open fun attachHost(@Nullable parent: Fragment?): Unit

Attaches the host to the FragmentManager for this controller. The host must be attached before the FragmentManager can be used to manage Fragments.

createController

@NonNull open static fun createController(@NonNull callbacks: FragmentHostCallback<*>): FragmentController

Returns a FragmentController.

dispatchActivityCreated

open fun dispatchActivityCreated(): Unit

Moves all Fragments managed by the controller's FragmentManager into the activity created state.

Call when Fragments should be informed their host has been created.

See Also

    dispatchConfigurationChanged

    open fun dispatchConfigurationChanged(@NonNull newConfig: Configuration): Unit

    Lets all Fragments managed by the controller's FragmentManager know a configuration change occurred.

    Call when there is a configuration change.

    dispatchContextItemSelected

    open fun dispatchContextItemSelected(@NonNull item: MenuItem): Boolean

    Sends a context item selection event to the Fragments managed by the controller's FragmentManager. Once the event has been consumed, no additional handling will be performed.

    Call immediately after an options menu item has been selected

    Return
    Boolean true if the context menu selection event was consumed

    dispatchCreate

    open fun dispatchCreate(): Unit

    Moves all Fragments managed by the controller's FragmentManager into the create state.

    Call when Fragments should be created.

    See Also

      dispatchCreateOptionsMenu

      open fun dispatchCreateOptionsMenu(
          @NonNull menu: Menu,
          @NonNull inflater: MenuInflater
      ): Boo