# FragmentResultOwner

Artifact: [androidx.fragment:fragment](https://developer.android.com/jetpack/androidx/releases/fragment) [View Source](https://cs.android.com/search?q=file:androidx/fragment/app/FragmentResultOwner.java+class:androidx.fragment.app.FragmentResultOwner) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.3.0)

*** ** * ** ***


```
public interface FragmentResultOwner
```

<br />

Known direct subclasses [FragmentManager](https://developer.android.com/reference/androidx/fragment/app/FragmentManager)

|---|---|
| `https://developer.android.com/reference/androidx/fragment/app/FragmentManager` | Static library support version of the framework's `https://developer.android.com/reference/android/app/FragmentManager.html`. |

*** ** * ** ***

A class that manages passing data between fragments.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#clearFragmentResult(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html requestKey)` Clears the stored result for the given requestKey. |
| `abstract void` | `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#clearFragmentResultListener(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html requestKey)` Clears the stored `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` for the given requestKey. |
| `abstract void` | `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#setFragmentResult(java.lang.String,android.os.Bundle)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html requestKey, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/Bundle.html result)` Sets the given result for the requestKey. |
| `abstract void` | `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html requestKey, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner lifecycleOwner, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener listener )` Sets the `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` for a given requestKey. |

## Public methods

### clearFragmentResult

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/fragment#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 `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#setFragmentResult(java.lang.String,android.os.Bundle)` that hasn't yet been delivered to a `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html requestKey` | key used to identify the result |

### clearFragmentResultListener

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.3.0)

```
abstract void clearFragmentResultListener(@NonNull String requestKey)
```

Clears the stored `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` for the given requestKey. This clears any `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` that was previously set via `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html requestKey` | key used to identify the result |

### setFragmentResult

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/fragment#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 `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` that is called given to `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)` with the same requestKey. If no `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` with the same key is set or the Lifecycle associated with the listener is not at least `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#STARTED`, the result is stored until one becomes available, or `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#clearFragmentResult(java.lang.String)` is called with the same requestKey.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html requestKey` | key used to identify the result |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/Bundle.html result` | the result to be passed to another fragment |

### setFragmentResultListener

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.3.0)

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

Sets the `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` for a given requestKey. Once the given `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` is at least in the `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#STARTED` state, any results set by `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#setFragmentResult(java.lang.String,android.os.Bundle)` using the same requestKey will be delivered to the `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener#onFragmentResult(java.lang.String,android.os.Bundle)`. The callback will remain active until the LifecycleOwner reaches the `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#DESTROYED` state or `https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner#clearFragmentResultListener(java.lang.String)` is called with the same requestKey.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html requestKey` | requestKey used to identify the result |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner lifecycleOwner` | lifecycleOwner for handling the result |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener listener` | listener for result changes |