Android APIs
public class

FragmentController

extends Object
java.lang.Object
   ↳ android.app.FragmentController

Class Overview

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
void attachHost(Fragment parent)
Attaches the host to the FragmentManager for this controller.
final static FragmentController createController(FragmentHostCallback<?> callbacks)
Returns a FragmentController.
void dispatchActivityCreated()
Moves all Fragments managed by the controller's FragmentManager into the activity created state.
void dispatchConfigurationChanged(Configuration newConfig)
Lets all Fragments managed by the controller's FragmentManager know a configuration change occurred.
boolean dispatchContextItemSelected(MenuItem item)
Sends a context item selection event to the Fragments managed by the controller's FragmentManager.
void dispatchCreate()
Moves all Fragments managed by the controller's FragmentManager into the create state.
boolean dispatchCreateOptionsMenu(Menu menu, MenuInflater inflater)
Lets all Fragments managed by the controller's FragmentManager know they should create an options menu.
void dispatchDestroy()
Moves all Fragments managed by the controller's FragmentManager into the destroy state.
void dispatchDestroyView()
Moves all Fragments managed by the controller's FragmentManager into the destroy view state.
void dispatchLowMemory()
Lets all Fragments managed by the controller's FragmentManager know the device is in a low memory condition.
boolean dispatchOptionsItemSelected(MenuItem item)
Sends an option item selection event to the Fragments managed by the controller's FragmentManager.
void dispatchOptionsMenuClosed(Menu menu)
Lets all Fragments managed by the controller's FragmentManager know their options menu has closed.
void dispatchPause()
Moves all Fragments managed by the controller's FragmentManager into the pause state.
boolean dispatchPrepareOptionsMenu(Menu menu)
Lets all Fragments managed by the controller's FragmentManager know they should prepare their options menu for display.
void dispatchResume()
Moves all Fragments managed by the controller's FragmentManager into the resume state.
void dispatchStart()
Moves all Fragments managed by the controller's FragmentManager into the start state.
void dispatchStop()
Moves all Fragments managed by the controller's FragmentManager into the stop state.
void dispatchTrimMemory(int level)
Lets all Fragments managed by the controller's FragmentManager know they should trim their memory usage.
void doLoaderDestroy()
Destroys the loaders and, if their state is not being retained, removes them.
void doLoaderStart()
Starts the loaders.
void doLoaderStop(boolean retain)
Stops the loaders, optionally retaining their state.
void dumpLoaders(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
Dumps the current state of the loaders.
boolean execPendingActions()
Execute any pending actions for the Fragments managed by the controller's FragmentManager.
Fragment findFragmentByWho(String who)
Returns a fragment with the given identifier.
FragmentManager getFragmentManager()
Returns a FragmentManager for this controller.
LoaderManager getLoaderManager()
Returns a LoaderManager.
void noteStateNotSaved()
Marks the fragment state as unsaved.
View onCreateView(View parent, String name, Context context, AttributeSet attrs)
Instantiates a Fragment's view.
void reportLoaderStart()
Lets the loaders know the host is ready to receive notifications.
void restoreAllState(Parcelable state, List<Fragment> nonConfigList)
Restores the saved state for all Fragments.
void restoreLoaderNonConfig(ArrayMap<StringLoaderManager> loaderManagers)
Restores the saved state for all LoaderManagers.
ArrayMap<StringLoaderManager> retainLoaderNonConfig()
Returns a list of LoaderManagers that have opted to retain their instance across configuration changes.
List<Fragment> retainNonConfig()
Returns a list of Fragments that have opted to retain their instance across configuration changes.
Parcelable saveAllState()
Saves the state for all Fragments.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void attachHost (Fragment parent)

Added in API level 23

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

public static final FragmentController createController (FragmentHostCallback<?> callbacks)

Added in API level 23

Returns a FragmentController.

public void dispatchActivityCreated ()

Added in API level 23

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.

public void dispatchConfigurationChanged (Configuration newConfig)

Added in API level 23

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

Call when there is a configuration change.

public boolean dispatchContextItemSelected (MenuItem item)

Added in API level 23

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

Returns
  • true if the context menu selection event was consumed

public void dispatchCreate ()

Added in API level 23

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

Call when Fragments should be created.

See Also

public boolean dispatchCreateOptionsMenu (Menu menu, MenuInflater inflater)

Added in API level 23

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.

Returns
  • true if the options menu contains items to display

public void dispatchDestroy ()

Added in API level 23

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

Call when Fragments should be destroyed.

See Also

public void dispatchDestroyView ()

Added in API level 23

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

Call when the Fragment's views should be destroyed.

See Also

public void dispatchLowMemory ()

Added in API level 23

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.

See Also

public boolean dispatchOptionsItemSelected (MenuItem item)

Added in API level 23

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

Returns
  • true if the options menu selection event was consumed

public void dispatchOptionsMenuClosed (Menu menu)

Added in API level 23

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

Call immediately after closing the Fragment's options menu.

public void dispatchPause ()

Added in API level 23

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

Call when Fragments should be paused.

See Also

public boolean dispatchPrepareOptionsMenu (Menu menu)

Added in API level 23

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.

Returns
  • true if the options menu contains items to display

public void dispatchResume ()

Added in API level 23

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

Call when Fragments should be resumed.

See Also

public void dispatchStart ()

Added in API level 23

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

Call when Fragments should be started.

See Also

public void dispatchStop ()

Added in API level 23

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

Call when Fragments should be stopped.

See Also

public void dispatchTrimMemory (int level)

Added in API level 23

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

public void doLoaderDestroy ()

Added in API level 23

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

public void doLoaderStart ()

Added in API level 23

Starts the loaders.

public void doLoaderStop (boolean retain)

Added in API level 23

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

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

public void dumpLoaders (String prefix, FileDescriptor fd, PrintWriter writer, String[] args)

Added in API level 23

Dumps the current state of the loaders.

public boolean execPendingActions ()

Added in API level 23

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

Returns
  • true if queued actions were performed

public Fragment findFragmentByWho (String who)

Added in API level 23

Returns a fragment with the given identifier.

public FragmentManager getFragmentManager ()

Added in API level 23

Returns a FragmentManager for this controller.

public LoaderManager getLoaderManager ()

Added in API level 23

Returns a LoaderManager.

public void noteStateNotSaved ()

Added in API level 23

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

public View onCreateView (View parent, String name, Context context, AttributeSet attrs)

Added in API level 23

Instantiates a Fragment's view.

Parameters
parent The parent that the created view will be placed in; note that this may be null.
name Tag name to be inflated.
context The context the view is being created in.
attrs Inflation attributes as specified in XML file.
Returns
  • view the newly created view

public void reportLoaderStart ()

Added in API level 23

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

public void restoreAllState (Parcelable state, List<Fragment> nonConfigList)

Added in API level 23

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

public void restoreLoaderNonConfig (ArrayMap<StringLoaderManager> loaderManagers)

Added in API level 23

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

public ArrayMap<StringLoaderManager> retainLoaderNonConfig ()

Added in API level 23

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

public List<Fragment> retainNonConfig ()

Added in API level 23

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

public Parcelable saveAllState ()

Added in API level 23

Saves the state for all Fragments.