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

FragmentActivity

open class FragmentActivity : ComponentActivity, ActivityCompat.OnRequestPermissionsResultCallback, RequestPermissionsRequestCodeValidator
androidx.activity.ComponentActivity
   ↳ androidx.fragment.app.FragmentActivity

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.

<init>(@LayoutRes contentLayoutId: Int)

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

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

Print the Activity's state into the given stream.

open FragmentManager

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

open LoaderManager

open Unit
onAttachFragment(@NonNull fragment: Fragment)

Called when a fragment is attached to the activity.

open Unit

Dispatch configuration change to all fragments.

open Boolean
onCreatePanelMenu(featureId: Int, @NonNull menu: Menu)

Dispatch to Fragment.

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

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

open Unit

Dispatch onLowMemory() to all fragments.

open Boolean
onMenuItemSelected(featureId: Int, @NonNull item: MenuItem)

Dispatch context and options menu to fragments.

open Unit
onMultiWindowModeChanged(isInMultiWindowMode: Boolean)

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

open Unit
onPanelClosed(featureId: Int, @NonNull menu: Menu)

Call onOptionsMenuClosed() on fragments.

open Unit
onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)

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

open Boolean
onPreparePanel(featureId: Int, @Nullable view: View?, @NonNull menu: Menu)

Dispatch onPrepareOptionsMenu() to fragments.

open Unit
onRequestPermissionsResult(requestCode: Int, @NonNull permissions: Array<String!>, @NonNull grantResults: IntArray)

open Unit

Hook in to note that fragment state is no longer saved.

open Unit

When android.app.ActivityOptions#makeSceneTransitionAnimation(Activity, * android.view.View, String) was used to start an Activity, callback will be called to handle shared elements on the launched Activity.

open Unit

When android.app.ActivityOptions#makeSceneTransitionAnimation(Activity, * android.view.View, String) was used to start an Activity, listener will be called to handle shared elements on the launching Activity.

open Unit
startActivityFromFragment(@NonNull fragment: Fragment, intent: Intent!, requestCode: Int)

Called by Fragment.

open Unit
startActivityFromFragment(@NonNull fragment: Fragment, intent: Intent!, requestCode: Int, @Nullable options: Bundle?)

Called by Fragment.

open Unit
startIntentSenderFromFragment(@NonNull fragment: Fragment, intent: IntentSender!, requestCode: Int, @Nullable fillInIntent: Intent?, flagsMask: Int, flagsValues: Int, extraFlags: Int, @Nullable options: Bundle?)

Called by Fragment.

open Unit

Reverses the Activity Scene entry Transition and triggers the calling Activity to reverse its exit Transition.

open Unit

Support library version of Activity#invalidateOptionsMenu.

open Unit

Support library version of android.app.Activity#postponeEnterTransition() that works only on API 21 and later.

open Unit

Support library version of android.app.Activity#startPostponedEnterTransition() that only works with API 21 and later.

Unit

Protected methods
open Unit
onActivityResult(requestCode: Int, resultCode: Int, @Nullable data: Intent?)

open Unit
onCreate(@Nullable savedInstanceState: Bundle?)

Perform initialization of all fragments.

open Unit

Destroy all fragments.

open Unit
onNewIntent(intent: Intent!)

Handle onNewIntent() to inform the fragment manager that the state is not saved.

open Unit

Dispatch onPause() to fragments.

open Unit

Dispatch onResume() to fragments.

open Unit

Dispatch onResume() to fragments.

open Unit

This is the fragment-orientated version of onResume() that you can override to perform operations in the Activity at the same point where its fragments are resumed.

open Unit

Dispatch onStart() to all fragments.

open Unit

Dispatch onStop() to all fragments.

Inherited functions