FragmentResultOwner


interface FragmentResultOwner

Known direct subclasses
FragmentManager

Static library support version of the framework's android.app.FragmentManager.


A class that manages passing data between fragments.

Summary

Public functions

Unit

Clears the stored result for the given requestKey.

Unit

Clears the stored FragmentResultListener for the given requestKey.

Unit
setFragmentResult(requestKey: String, result: Bundle)

Sets the given result for the requestKey.

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

Sets the FragmentResultListener for a given requestKey.

Public functions

clearFragmentResult

Added in 1.3.0
fun clearFragmentResult(requestKey: String): Unit

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

Parameters
requestKey: String

key used to identify the result

clearFragmentResultListener

Added in 1.3.0
fun clearFragmentResultListener(requestKey: String): Unit

Clears the stored FragmentResultListener for the given requestKey. This clears any FragmentResultListener that was previously set via setFragmentResultListener.

Parameters
requestKey: String

key used to identify the result

setFragmentResult

Added in 1.3.0
fun setFragmentResult(requestKey: String, result: Bundle): Unit

Sets the given result for the requestKey. This result will be delivered to a FragmentResultListener that is called given to setFragmentResultListener with the same requestKey. If no FragmentResultListener with the same key is set or the Lifecycle associated with the listener is not at least STARTED, the result is stored until one becomes available, or clearFragmentResult 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

Added in 1.3.0
fun setFragmentResultListener(
    requestKey: String,
    lifecycleOwner: LifecycleOwner,
    listener: FragmentResultListener
): Unit

Sets the FragmentResultListener for a given requestKey. Once the given LifecycleOwner is at least in the STARTED state, any results set by setFragmentResult using the same requestKey will be delivered to the callback. The callback will remain active until the LifecycleOwner reaches the DESTROYED state or clearFragmentResultListener 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