FragmentResultOwner

interface FragmentResultOwner
androidx.fragment.app.FragmentResultOwner

A class that manages passing data between fragments.

Summary

Public methods
abstract Unit
clearFragmentResult(@NonNull requestKey: String)

Clears the stored result for the given requestKey.

abstract Unit
clearFragmentResultListener(@NonNull requestKey: String)

Clears the stored FragmentResultListener for the given requestKey.

abstract Unit
setFragmentResult(@NonNull requestKey: String, @NonNull result: Bundle)

Sets the given result for the requestKey.

abstract Unit
setFragmentResultListener(@NonNull requestKey: String, @NonNull lifecycleOwner: LifecycleOwner, @NonNull listener: FragmentResultListener)

Sets the FragmentResultListener for a given requestKey.

Extension functions
From androidx.fragment.app
Unit
FragmentResultOwner.setFragmentResultListener(requestKey: String, lifecycleOwner: LifecycleOwner, crossinline listener: (requestKey: String, bundle: Bundle) -> Unit)

Sets the FragmentResultListener for a given requestKey.

Public methods

clearFragmentResult

abstract fun clearFragmentResult(@NonNull requestKey: String): Unit

Clears the stored result for the given requestKey. This clears any result that was previously set via setFragmentResult(String, Bundle) that hasn't yet been delivered to a FragmentResultListener.

Parameters
requestKey String: key used to identify the result

clearFragmentResultListener

abstract fun clearFragmentResultListener(@NonNull requestKey: String): Unit

Clears the stored FragmentResultListener for the given requestKey. This clears any FragmentResultListener that was previously set via setFragmentResultListener(String, LifecycleOwner, FragmentResultListener).

Parameters
requestKey String: key used to identify the result

setFragmentResult

abstract fun setFragmentResult(
    @NonNull requestKey: String,
    @NonNull result: Bundle
): Unit

Sets the given result for the requestKey. This result will be delivered to a FragmentResultListener that is called given to setFragmentResultListener(String, LifecycleOwner, FragmentResultListener) with the same requestKey. If no FragmentResultListener with the same key is set or the Lifecycle associated with the listener is not at least androidx.lifecycle.Lifecycle.State#STARTED, the result is stored until one becomes available, or clearFragmentResult(String) is called with the same requestKey.

Parameters
requestKey String: key used to identify the result
result Bundle: the result to be passed to another fragment

setFragmentResultListener

abstract fun setFragmentResultListener(
    @NonNull requestKey: String,
    @NonNull lifecycleOwner: LifecycleOwner,
    @NonNull listener: FragmentResultListener
): Unit

Sets the FragmentResultListener for a given requestKey. Once the given LifecycleOwner is at least in the androidx.lifecycle.Lifecycle.State#STARTED state, any results set by setFragmentResult(String, Bundle) using the same requestKey will be delivered to the callback. The callback will remain active until the LifecycleOwner reaches the androidx.lifecycle.Lifecycle.State#DESTROYED state or clearFragmentResultListener(String) is called with the same requestKey.

Parameters
requestKey String: requestKey used to identify the result
lifecycleOwner LifecycleOwner: lifecycleOwner for handling the result
listener FragmentResultListener: listener for result changes