FragmentActivity

public class FragmentActivity extends ComponentActivity implements ContextAware, LifecycleOwner, ViewModelStoreOwner, HasDefaultViewModelProviderFactory, LifecycleOwner, SavedStateRegistryOwner, LifecycleOwner, OnBackPressedDispatcherOwner, ActivityResultRegistryOwner, ActivityResultCaller, MenuHost, ActivityCompat.OnRequestPermissionsResultCallback

Object
   ↳ ComponentActivity
     ↳ FragmentActivity
Known direct subclasses
AppCompatActivity

Base class for activities that wish to use some of the newer platform features on older Android devices.

CarAppActivity

The class representing a car app activity.


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

Summary

Public constructors

Default constructor for FragmentActivity.

FragmentActivity(@LayoutRes @NonNull 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

@Override @NonNull void
dump(
    @NonNull String prefix,
    @Nullable FileDescriptor fd,
    @NonNull PrintWriter writer,
    @Nullable String[] args
)

Print the Activity's state into the given stream.

@NonNull FragmentManager

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

@NonNull LoaderManager

This method is deprecated.

Use LoaderManager.getInstance(this).

@MainThread @NonNull void

This method is deprecated.

The responsibility for listening for fragments being attached has been moved to FragmentManager.

@Override @NonNull void

Dispatch configuration change to all fragments.

@Override @NonNull boolean
onCreatePanelMenu(@NonNull int featureId, @NonNull Menu menu)

Dispatch to Fragment.onCreateOptionsMenu().

@Override @Nullable View
onCreateView(
    @Nullable View parent,
    @NonNull String name,
    @NonNull Context context,
    @NonNull AttributeSet attrs
)
@Override @Nullable View
onCreateView(
    @NonNull String name,
    @NonNull Context context,
    @NonNull AttributeSet attrs
)
@Override @NonNull void

Dispatch onLowMemory() to all fragments.

@Override @NonNull boolean
onMenuItemSelected(@NonNull int featureId, @NonNull MenuItem item)

Dispatch context and options menu to fragments.

@Override @CallSuper @NonNull void
onMultiWindowModeChanged(@NonNull 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.

@Override @NonNull void
onPanelClosed(@NonNull int featureId, @NonNull Menu menu)

Call onOptionsMenuClosed() on fragments.

@Override @CallSuper @NonNull void
onPictureInPictureModeChanged(@NonNull 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.

@Override @NonNull boolean
onPreparePanel(
    @NonNull int featureId,
    @Nullable View view,
    @NonNull Menu menu
)

Dispatch onPrepareOptionsMenu() to fragments.

@CallSuper @Override @NonNull void
onRequestPermissionsResult(
    @NonNull int requestCode,
    @