Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

FragmentHostCallback

abstract class FragmentHostCallback<E : Any!> : FragmentContainer
kotlin.Any
   ↳ androidx.fragment.app.FragmentContainer
   ↳ androidx.fragment.app.FragmentHostCallback

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.

Summary

Public constructors
<init>(@NonNull context: Context, @NonNull handler: Handler, windowAnimations: Int)

Public methods
open Unit
onStartActivityFromFragment(@NonNull fragment: Fragment, intent: Intent!, requestCode: Int)

Starts a new Activity from the given fragment.

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

Starts a new Activity from the given fragment.

abstract E?

Return the object that's currently hosting the fragment.

open LayoutInflater

Return a LayoutInflater.

open Int

Return the window animations.

open Boolean

Checks whether to show permission rationale UI from a fragment.

open Boolean

Return true if there are window animations.

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

Print internal state into the given stream.

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

Starts a new IntentSender from the given fragment.

open Unit

Invalidates the activity's options menu.

open Boolean

open Unit
onRequestPermissionsFromFragment(@NonNull fragment: Fragment, @NonNull permissions: Array<String!>, requestCode: Int)

Requests permissions from the given fragment.

open Boolean
onShouldSaveFragmentState(@NonNull fragment: Fragment)

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

open View?

Inherited functions

Public constructors

<init>

FragmentHostCallback(@NonNull context: Context, @NonNull handler: Handler, windowAnimations: Int)

Public methods

onStartActivityFromFragment

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

Starts a new Activity from the given fragment. See FragmentActivity#startActivityForResult(Intent, int).

onStartActivityFromFragment

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

Starts a new Activity from the given fragment. See FragmentActivity#startActivityForResult(Intent, int, Bundle).

onGetHost

@Nullable abstract fun onGetHost(): E?

Return the object that's currently hosting the fragment. If a Fragment is hosted by a FragmentActivity, the object returned here should be the same object returned from Fragment#getActivity().

onGetLayoutInflater

@NonNull open fun onGetLayoutInflater(): LayoutInflater

Return a LayoutInflater. See Activity#getLayoutInflater().

onGetWindowAnimations

open fun onGetWindowAnimations(): Int

Return the window animations.

onShouldShowRequestPermissionRationale

open fun onShouldShowRequestPermissionRationale(@NonNull permission: String): Boolean

Checks whether to show permission rationale UI from a fragment. See FragmentActivity#shouldShowRequestPermissionRationale(String)

onHasWindowAnimations

open fun onHasWindowAnimations(): Boolean

Return true if there are window animations.

onDump

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

Print internal state into the given stream.

Parameters
prefix String: Desired prefix to prepend at each line of output.
fd String: The raw file descriptor that the dump is being sent to.
writer String: The PrintWriter to which you should dump your state. This will be closed for you after you return.
args String: additional arguments to the dump request.

onStartIntentSenderFromFragment

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

Starts a new IntentSender from the given fragment. See Activity#startIntentSender(IntentSender, Intent, int, int, int, Bundle).

onSupportInvalidateOptionsMenu

open fun onSupportInvalidateOptionsMenu(): Unit

Invalidates the activity's options menu. See FragmentActivity#supportInvalidateOptionsMenu()

onHasView

open fun onHasView(): Boolean

onRequestPermissionsFromFragment

open fun onRequestPermissionsFromFragment(@NonNull fragment: Fragment, @NonNull permissions: Array<String!>, requestCode: Int): Unit

Requests permissions from the given fragment. See FragmentActivity#requestPermissions(String[], int)

onShouldSaveFragmentState

open fun onShouldSaveFragmentState(@NonNull fragment: Fragment): Boolean

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

onFindViewById

@Nullable open fun onFindViewById(id: Int): View?