Added in API level 23
Deprecated in API level 28

FragmentController


open class FragmentController
kotlin.Any
   ↳ android.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(parent: Fragment!)

Attaches the host to the FragmentManager for this controller.

static FragmentController!

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

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

open Unit

Moves all 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 Unit
dispatchMultiWindowModeChanged(isInMultiWindowMode: Boolean, newConfig: Configuration!)

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 Unit
dispatchPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration!)

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

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

Lets all Fragments managed by the controller's FragmentManager know they should trim their memory usage.

open Unit

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

open Unit

Starts the loaders.

open Unit

Stops the loaders, optionally retaining their state.

open Unit
dumpLoaders(prefix: String!, fd: FileDescriptor!, writer: PrintWriter!, 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?

Returns a fragment with the given identifier.

open FragmentManager!

Returns a FragmentManager for this controller.

open LoaderManager!

Returns a LoaderManager.

open Unit

Marks the fragment state as unsaved.

open View!
onCreateView(parent: View!, name: String!, context: Context!, attrs: AttributeSet!)

Instantiates a Fragment's view.

open Unit

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

open Unit

Restores the saved state for all Fragments.

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

Restores the saved state for all Fragments.

open Unit

Restores the saved state for all LoaderManagers.

open ArrayMap<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

Added in API level 23
open fun attachHost(parent: Fragment!): Unit

Deprecated: Deprecated in Java.

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

createController

Added in API level 23
static fun createController(callbacks: FragmentHostCallback<*>!): FragmentController!

Deprecated: Deprecated in Java.

Returns a FragmentController.

dispatchActivityCreated

Added in API level 23
open fun dispatchActivityCreated(): Unit

Deprecated: Deprecated in Java.

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.

dispatchConfigurationChanged

Added in API level 23
open fun dispatchConfigurationChanged(newConfig: Configuration!): Unit

Deprecated: Deprecated in Java.

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

Call when there is a configuration change.

dispatchContextItemSelected

Added in API level 23
open fun dispatchContextItemSelected(item: MenuItem!): Boolean

Deprecated: Deprecated in Java.

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

Added in API level 23
open fun dispatchCreate(): Unit

Deprecated: Deprecated in Java.

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

Call when Fragments should be created.

dispatchCreateOptionsMenu

Added in API level 23
open fun dispatchCreateOptionsMenu(
    menu: Menu!,
    inflater: MenuInflater!
): Boolean

Deprecated: Deprecated in Java.

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

Call when the Fragment should create an options menu.

Return
Boolean true if the options menu contains items to display

dispatchDestroy

Added in API level 23
open fun dispatchDestroy(): Unit

Deprecated: Deprecated in Java.

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

Call when Fragments should be destroyed.

dispatchDestroyView

Added in API level 23
open fun dispatchDestroyView(): Unit

Deprecated: Deprecated in Java.

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

Call when the Fragment's views should be destroyed.

dispatchLowMemory

Added in API level 23
open fun dispatchLowMemory(): Unit

Deprecated: Deprecated in Java.

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

Call when the device is low on memory and Fragment's should trim their memory usage.

dispatchMultiWindowModeChanged

Added in API level 24
Deprecated in API level 26
open fun dispatchMultiWindowModeChanged(isInMultiWindowMode: Boolean): Unit

Deprecated: use dispatchMultiWindowModeChanged(boolean,android.content.res.Configuration)

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

Call when the multi-window mode of the activity changed.

See Also

    dispatchMultiWindowModeChanged

    Added in API level 26
    Deprecated in API level 28
    open fun dispatchMultiWindowModeChanged(
        isInMultiWindowMode: Boolean,
        newConfig: Configuration!
    ): Unit

    Deprecated: Deprecated in Java.

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

    Call when the multi-window mode of the activity changed.

    See Also

      dispatchOptionsItemSelected

      Added in API level 23
      open fun dispatchOptionsItemSelected(item: MenuItem!): Boolean

      Deprecated: Deprecated in Java.

      Sends an option 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 options menu selection event was consumed

      dispatchOptionsMenuClosed

      Added in API level 23
      open fun dispatchOptionsMenuClosed(menu: Menu!): Unit

      Deprecated: Deprecated in Java.

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

      Call immediately after closing the Fragment's options menu.

      dispatchPause

      Added in API level 23
      open fun dispatchPause(): Unit

      Deprecated: Deprecated in Java.

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

      Call when Fragments should be paused.

      dispatchPictureInPictureModeChanged

      Added in API level 24
      Deprecated in API level 26
      open fun dispatchPictureInPictureModeChanged(isInPictureInPictureMode: Boolean): Unit

      Deprecated: use dispatchPictureInPictureModeChanged(boolean,android.content.res.Configuration)

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

      Call when the picture-in-picture mode of the activity changed.

      See Also

        dispatchPictureInPictureModeChanged

        Added in API level 26
        Deprecated in API level 28
        open fun dispatchPictureInPictureModeChanged(
            isInPictureInPictureMode: Boolean,
            newConfig: Configuration!
        ): Unit

        Deprecated: Deprecated in Java.

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

        Call when the picture-in-picture mode of the activity changed.

        See Also

          dispatchPrepareOptionsMenu

          Added in API level 23
          open fun dispatchPrepareOptionsMenu(menu: Menu!): Boolean

          Deprecated: Deprecated in Java.

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

          Call immediately before displaying the Fragment's options menu.

          Return
          Boolean true if the options menu contains items to display

          dispatchResume

          Added in API level 23
          open fun dispatchResume(): Unit

          Deprecated: Deprecated in Java.

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

          Call when Fragments should be resumed.

          dispatchStart

          Added in API level 23
          open fun dispatchStart(): Unit

          Deprecated: Deprecated in Java.

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

          Call when Fragments should be started.

          dispatchStop

          Added in API level 23
          open fun dispatchStop(): Unit

          Deprecated: Deprecated in Java.

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

          Call when Fragments should be stopped.

          dispatchTrimMemory

          Added in API level 23
          open fun dispatchTrimMemory(level: Int): Unit

          Deprecated: Deprecated in Java.

          Lets all Fragments managed by the controller's FragmentManager know they should trim their memory usage.

          Call when the Fragment can release allocated memory [such as if the Fragment is in the background].

          doLoaderDestroy

          Added in API level 23
          open fun doLoaderDestroy(): Unit

          Deprecated: Deprecated in Java.

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

          doLoaderStart

          Added in API level 23
          open fun doLoaderStart(): Unit

          Deprecated: Deprecated in Java.

          Starts the loaders.

          doLoaderStop

          Added in API level 23
          open fun doLoaderStop(retain: Boolean): Unit

          Deprecated: Deprecated in Java.

          Stops the loaders, optionally retaining their state. This is useful for keeping the loader state across configuration changes.

          Parameters
          retain Boolean: When true, the loaders aren't stopped, but, their instances are retained in a started state

          dumpLoaders

          Added in API level 23
          open fun dumpLoaders(
              prefix: String!,
              fd: FileDescriptor!,
              writer: PrintWriter!,
              args: Array<String!>!
          ): Unit

          Deprecated: Deprecated in Java.

          Dumps the current state of the loaders.

          execPendingActions

          Added in API level 23
          open fun execPendingActions(): Boolean

          Deprecated: Deprecated in Java.

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

          Call when queued actions can be performed [eg when the Fragment moves into a start or resume state].

          Return
          Boolean true if queued actions were performed

          findFragmentByWho

          Added in API level 23
          open fun findFragmentByWho(who: String!): Fragment?

          Deprecated: Deprecated in Java.

          Returns a fragment with the given identifier.

          Return
          Fragment? This value may be null.

          getFragmentManager

          Added in API level 23
          open fun getFragmentManager(): FragmentManager!

          Deprecated: Deprecated in Java.

          Returns a FragmentManager for this controller.

          getLoaderManager

          Added in API level 23
          open fun getLoaderManager(): LoaderManager!

          Deprecated: Deprecated in Java.

          Returns a LoaderManager.

          noteStateNotSaved

          Added in API level 23
          open fun noteStateNotSaved(): Unit

          Deprecated: Deprecated in Java.

          Marks the fragment state as unsaved. This allows for "state loss" detection.

          onCreateView

          Added in API level 23
          open fun onCreateView(
              parent: View!,
              name: String!,
              context: Context!,
              attrs: AttributeSet!
          ): View!

          Deprecated: Deprecated in Java.

          Instantiates a Fragment's view.

          Parameters
          parent View!: The parent that the created view will be placed in; note that this may be null.
          name String!: Tag name to be inflated.
          context Context!: The context the view is being created in.
          attrs AttributeSet!: Inflation attributes as specified in XML file.
          Return
          View! view the newly created view

          reportLoaderStart

          Added in API level 23
          open fun reportLoaderStart(): Unit

          Deprecated: Deprecated in Java.

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

          restoreAllState

          Added in API level 24
          Deprecated in API level 28
          open fun restoreAllState(
              state: Parcelable!,
              nonConfig: FragmentManagerNonConfig!
          ): Unit

          Deprecated: Deprecated in Java.

          Restores the saved state for all Fragments. The given FragmentManagerNonConfig are Fragment instances retained across configuration changes, including nested fragments

          restoreAllState

          Added in API level 23
          Deprecated in API level 24
          open fun restoreAllState(
              state: Parcelable!,
              nonConfigList: MutableList<Fragment!>!
          ): Unit

          Deprecated: use restoreAllState(android.os.Parcelable,android.app.FragmentManagerNonConfig)

          Restores the saved state for all Fragments. The given Fragment list are Fragment instances retained across configuration changes.

          restoreLoaderNonConfig

          Added in API level 23
          open fun restoreLoaderNonConfig(loaderManagers: ArrayMap<String!, LoaderManager!>!): Unit

          Deprecated: Deprecated in Java.

          Restores the saved state for all LoaderManagers. The given LoaderManager list are LoaderManager instances retained across configuration changes.

          retainLoaderNonConfig

          Added in API level 23
          open fun retainLoaderNonConfig(): ArrayMap<String!, LoaderManager!>!

          Deprecated: Deprecated in Java.

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

          retainNestedNonConfig

          Added in API level 24
          Deprecated in API level 28
          open fun retainNestedNonConfig(): FragmentManagerNonConfig!

          Deprecated: Deprecated in Java.

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

          retainNonConfig

          Added in API level 23
          Deprecated in API level 24
          open fun retainNonConfig(): MutableList<Fragment!>!

          Deprecated: use retainNestedNonConfig() to also track retained nested child fragments

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

          saveAllState

          Added in API level 23
          open fun saveAllState(): Parcelable!

          Deprecated: Deprecated in Java.

          Saves the state for all Fragments.