FragmentHostCallback

public abstract class FragmentHostCallback<E> extends FragmentContainer


Integration points with the Fragment host.

Fragments may be hosted by any object; such as an Activity. In order to host fragments, implement FragmentHostCallback, overriding the methods applicable to the host.

FragmentManager changes its behavior based on what optional interfaces your FragmentHostCallback implements. This includes the following:

Parameters
<E>

the type of object that's currently hosting the fragments. An instance of this class must be returned by onGetHost.

Summary

Public constructors

FragmentHostCallback(
    @NonNull Context context,
    @NonNull Handler handler,
    @NonNull int windowAnimations
)

Public methods

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

Print internal state into the given stream.

@Nullable @Override View

Return the view with the given resource ID.

abstract @Nullable E

Return the object that's currently hosting the fragment.

@NonNull LayoutInflater

Return a LayoutInflater.

@NonNull int

Return the window animations.

@Override @NonNull boolean

Return true if the container holds any view.

@NonNull boolean

Return true if there are window animations.

@NonNull void
onRequestPermissionsFromFragment(
    @NonNull Fragment fragment,
    @NonNull String[] permissions,
    @NonNull int requestCode
)

This method is deprecated.

Have your FragmentHostCallback implement ActivityResultRegistryOwner to allow Fragments to use registerForActivityResult with RequestMultiplePermissions.

@NonNull boolean

Return true if the fragment's state needs to be saved.

@NonNull boolean

Checks whether to show permission rationale UI from a fragment.

@NonNull void
onStartActivityFromFragment(
    @NonNull Fragment fragment,
    @NonNull Intent intent,
    @NonNull int requestCode
)

Starts a new Activity from the given fragment.

@NonNull void
onStartActivityFromFragment(
    @NonNull Fragment fragment,
    @NonNull Intent intent,
    @NonNull int requestCode,
    @Nullable Bundle options
)

Starts a new Activity from the given fragment.

@NonNull void
onStartIntentSenderFromFragment(
    @NonNull Fragment fragment,
    @NonNull IntentSender intent,
    @NonNull int requestCode,
    @Nullable Intent fillInIntent,
    @NonNull int flagsMask,
    @NonNull int flagsValues,
    @NonNull int extraFlags,
    @Nullable Bundle options
)

This method is deprecated.

Have your FragmentHostCallback implement