BrandedSupportFragment | API reference | Android Developers
void
Print the Fragments's state into the given stream.
final boolean
Subclasses can not override equals().
final @Nullable FragmentActivity
Return the FragmentActivity this fragment is currently associated with.
boolean
Returns whether the the exit transition and enter transition overlap or not.
boolean
Returns whether the the return transition and reenter transition overlap or not.
final @Nullable Bundle
Return the arguments supplied when the fragment was instantiated, if any.
final @NonNull FragmentManager
Return a private FragmentManager for placing and managing Fragments inside of this Fragment.
@Nullable Context
Return the Context this fragment is currently associated with.
@NonNull CreationExtras
Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.
@NonNull ViewModelProvider.Factory
Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.
@Nullable Object
Returns the Transition that will be used to move Views into the initial scene.
@Nullable Object
Returns the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.
final @Nullable FragmentManager
This method is deprecated.
This has been removed in favor of getParentFragmentManager() which throws an IllegalStateException if the FragmentManager is null.
final @Nullable Object
Return the host object of this fragment.
final int
Return the identifier this fragment is known by.
final @NonNull LayoutInflater
Returns the cached LayoutInflater used to inflate Views of this Fragment.
@NonNull Lifecycle
Returns the Lifecycle of the provider.
@NonNull LoaderManager
This method is deprecated.
Use LoaderManager.getInstance(this).
final @Nullable Fragment
Returns the parent Fragment containing this Fragment.
final @NonNull FragmentManager
Return the FragmentManager for interacting with fragments associated with this fragment's activity.
@Nullable Object
Returns the Transition that will be used to move Views in to the scene when returning due to popping a back stack.
final @NonNull Resources
Return requireActivity().getResources().
final boolean
This method is deprecated.
Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.
@Nullable Object
Returns the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.
final @NonNull SavedStateRegistry
The SavedStateRegistry owned by this SavedStateRegistryOwner
@Nullable Object
Returns the Transition that will be used for shared elements transferred into the content Scene.
@Nullable Object
Return the Transition that will be used for shared elements transferred back during a pop of the back stack.
final @NonNull String
Return a localized string from the application's package's default string table.
final @NonNull String
Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined in java.util.Formatter and format.
final @Nullable String
Get the tag name of the fragment, if specified.
final @Nullable Fragment
This method is deprecated.
Instead of using a target fragment to pass results, use setFragmentResult to deliver results to FragmentResultListener instances registered by other fragments via setFragmentResultListener.
final int
This method is deprecated.
When using the target fragment replacement of setFragmentResultListener and setFragmentResult, consider using setArguments to pass a requestKey if you need to support dynamic request keys.
final @NonNull CharSequence
Return a localized, styled CharSequence from the application's package's default string table.
boolean
This method is deprecated.
Use setMaxLifecycle instead.
@Nullable View
Get the root view for the fragment's layout (the one returned by onCreateView), if provided.
@NonNull LifecycleOwner
Get a LifecycleOwner that represents the Fragment's View lifecycle.
@NonNull LiveData<LifecycleOwner>
Retrieve a LiveData which allows you to observe the lifecycle of the Fragment's View.
@NonNull ViewModelStore
Returns the ViewModelStore associated with this Fragment
final int
Subclasses can not override hashCode().
static @NonNull Fragment
This method is deprecated.
Use getFragmentFactory and instantiate
static @NonNull Fragment
This method is deprecated.
Use getFragmentFactory and instantiate, manually calling setArguments on the returned Fragment.
final boolean
Return true if the fragment is currently added to its activity.
final boolean
Return true if the fragment has been explicitly detached from the UI.
final boolean
Return true if the fragment has been hidden.
final boolean
Return true if the layout is included as part of an activity view hierarchy via the tag.
final boolean
Return true if this fragment is currently being removed from its activity.
final boolean
Return true if the fragment is in the resumed state.
final boolean
Returns true if this fragment is added and its state has already been saved by its host.
final boolean
Return true if the fragment is currently visible to the user.
void
This method is deprecated.
use onViewCreated for code touching the view created by onCreateView and onCreate for other initialization.
void
This method is deprecated.
This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.
void
This method is deprecated.
See onAttach.
void
Called when a fragment is first attached to its context.
void
This method is deprecated.
The responsibility for listening for fragments being attached has been moved to FragmentManager.
void
boolean
This hook is called whenever an item in a context menu is selected.
void
Called to do initial creation of a fragment.
@Nullable Animation
Called when a fragment loads an animation.
@Nullable Animator
Called when a fragment loads an animator.
void
Called when a context menu for the view is about to be shown.
void
This method is deprecated.
androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.
@Nullable View
Called to have the fragment instantiate its user interface view.
void
Called when the fragment is no longer in use.
void
This method is deprecated.
androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.
void
Called when the fragment is no longer attached to its activity.
@NonNull LayoutInflater
Returns the LayoutInflater used to inflate Views of this Fragment.
void
Called when the hidden state (as returned by isHidden of the fragment or another fragment in its hierarchy has changed.
void
This method is deprecated.
See onInflate.
void
Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.
void
This method is deprecated.
void
Called when the Fragment's activity changes from fullscreen mode to multi-window mode and visa-versa.
boolean
This method is deprecated.
androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.
void
This method is deprecated.
androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.
void
Called by the system when the activity changes to and from picture-in-picture mode.
void
This method is deprecated.
androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.
void
Callback for when the primary navigation state of this Fragment has changed.
void
This method is deprecated.
This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.
void
Called when the Fragment is no longer started.
void
Called when all saved state has been restored into the view hierarchy of the fragment.
void
Postpone the entering Fragment transition until startPostponedEnterTransition or executePendingTransactions has been called.
final void
Postpone the entering Fragment transition for a given amount of time and then call startPostponedEnterTransition.
final @NonNull ActivityResultLauncher<I>
Register a request to start an activity for result, designated by the given contract.
final @NonNull ActivityResultLauncher<I>
Register a request to start an activity for result, designated by the given contract.
void
Registers a context menu to be shown for the given view (multiple views can show the context menu).
final void
This method is deprecated.
This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.
final @NonNull FragmentActivity
Return the FragmentActivity this fragment is currently associated with.
final @NonNull Bundle
Return the arguments supplied when the fragment was instantiated.
final @NonNull Context
Return the Context this fragment is currently associated with.
final @NonNull FragmentManager
This method is deprecated.
This has been renamed to getParentFragmentManager() to make it clear that you are accessing the FragmentManager that contains this Fragment and not the FragmentManager associated with child Fragments.
final @NonNull Object
Return the host object of this fragment.
final @NonNull Fragment
Returns the parent Fragment containing this Fragment.
final @NonNull View
Get the root view for the fragment's layout (the one returned by onCreateView).
void
Sets whether the the exit transition and enter transition overlap or not.
void
Sets whether the the return transition and reenter transition overlap or not.
void
Supply the construction arguments for this fragment.
void
When custom transitions are used with Fragments, the enter transition callback is called when this Fragment is attached or detached when not popping the back stack.
void
Sets the Transition that will be used to move Views into the initial scene.
void
When custom transitions are used with Fragments, the exit transition callback is called when this Fragment is attached or detached when popping the back stack.
void
Sets the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.
void
This method is deprecated.
This method is no longer needed when using a MenuProvider to provide a Menu to your activity, which replaces onCreateOptionsMenu as the recommended way to provide a consistent, optionally Lifecycle-aware, and modular way to handle menu creation and item selection.
void
Set the initial saved state that this Fragment should restore itself from when first being constructed, as returned by FragmentManager.saveFragmentInstanceState.
void
Set a hint for whether this fragment's menu should be visible.
void
Sets the Transition that will be used to move Views in to the scene when returning due to popping a back stack.
void
This method is deprecated.
Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.
void
Sets the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.
void
Sets the Transition that will be used for shared elements transferred into the content Scene.
void
Sets the Transition that will be used for shared elements transferred back during a pop of the back stack.
void
This method is deprecated.
Instead of using a target fragment to pass results, the fragment requesting a result should use setFragmentResultListener to register a FragmentResultListener with a
requestKey using its parent fragment manager.
void
This method is deprecated.
If you are manually calling this method, use setMaxLifecycle instead.
boolean
Gets whether you should show UI with rationale before requesting a permission.
void
Call startActivity from the fragment's containing Activity.
void
Call startActivity from the fragment's containing Activity.
void
This method is deprecated.
This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.
void
This method is deprecated.
This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.
void
This method is deprecated.
This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.
void
Begin postponed transitions after postponeEnterTransition was called.
@NonNull String
void
Prevents a context menu to be shown for the given view.