public class FragmentActivity
extends ComponentActivity implements ActivityCompat.OnRequestPermissionsResultCallback

   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.view.ContextThemeWrapper
           ↳ androidx.activity.ComponentActivity

Base class for activities that want to use the support-based Fragments.

Known limitations:

  • When using the <fragment> tag, this implementation can not use the parent view's ID as the new fragment's ID. You must explicitly specify an ID (or tag) in the <fragment>.


Inherited constants

Inherited fields

Public constructors


Default constructor for FragmentActivity.

FragmentActivity(int contentLayoutId)

Alternate constructor that can be used to provide a default layout that will be inflated as part of super.onCreate(savedInstanceState).

Public methods

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

Print the Activity's state into the given stream.

FragmentManager getSupportFragmentManager()

Return the FragmentManager for interacting with fragments associated with this activity.

LoaderManager getSupportLoaderManager()

This method is deprecated. Use LoaderManager.getInstance(this).

void onAttachFragment(Fragment fragment)

This method is deprecated. The responsibility for listening for fragments being attached has been moved to FragmentManager. You can add a listener to this Activity's FragmentManager by calling FragmentManager.addFragmentOnAttachListener(FragmentOnAttachListener) in your constructor to get callbacks when a fragment is attached directly to the activity's FragmentManager.

void onConfigurationChanged(Configuration newConfig)

Dispatch configuration change to all fragments.

boolean onCreatePanelMenu(int featureId, Menu menu)

Dispatch to Fragment.onCreateOptionsMenu().

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

Dispatch onLowMemory() to all fragments.

boolean onMenuItemSelected(int featureId, MenuItem item)

Dispatch context and options menu to fragments.

void onMultiWindowModeChanged(boolean isInMultiWindowMode)

Note: If you override this method you must call super.onMultiWindowModeChanged to correctly dispatch the event to support fragments attached to this activity.

void onPanelClosed(int featureId, Menu menu)

Call onOptionsMenuClosed() on fragments.

void onPictureInPictureModeChanged(boolean isInPictureInPictureMode)

Note: If you override this method you must call super.onPictureInPictureModeChanged to correctly dispatch the event to support fragments attached to this activity.

boolean onPreparePanel(int featureId, View view, Menu menu)

Dispatch onPrepareOptionsMenu() to fragments.