FragmentResultOwner

public 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 methods

abstract void

Clears the stored result for the given requestKey.

abstract void

Clears the stored FragmentResultListener for the given requestKey.

abstract void
setFragmentResult(@NonNull String requestKey, @NonNull Bundle result)

Sets the given result for the requestKey.

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

Sets the FragmentResultListener for a given requestKey.

Public methods

clearFragmentResult

Added in 1.3.0
abstract void clearFragmentResult(@NonNull String requestKey)

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
@NonNull String requestKey

key used to identify the result

clearFragmentResultListener

Added in 1.3.0
abstract void clearFragmentResultListener(@NonNull String requestKey)

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

Parameters
@NonNull String requestKey

key used to identify the result

setFragmentResult

Added in 1.3.0
abstract void setFragmentResult(@NonNull String requestKey, @NonNull Bundle result)

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
@NonNull String requestKey

key used to identify the result

@NonNull Bundle result

the result to be passed to another fragment

setFragmentResultListener

Added in 1.3.0
abstract void setFragmentResultListener(
    @NonNull String requestKey,
    @NonNull LifecycleOwner lifecycleOwner,
    @NonNull FragmentResultListener listener
)

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
@NonNull String requestKey

requestKey used to identify the result

@NonNull LifecycleOwner lifecycleOwner

lifecycleOwner for handling the result

@NonNull FragmentResultListener listener

listener for result changes