# FragmentResultOwner

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/fragment/app/FragmentResultOwner "View this page in Java")

<br />

```
interface FragmentResultOwner
```

<br />

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

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

*** ** * ** ***

A class that manages passing data between fragments.

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [clearFragmentResult](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentResultOwner#clearFragmentResult(java.lang.String))`(requestKey: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Clears the stored result for the given requestKey.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [clearFragmentResultListener](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentResultOwner#clearFragmentResultListener(java.lang.String))`(requestKey: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Clears the stored[FragmentResultListener](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentResultListener)for the given requestKey.                                                                                                                                                                                                                                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setFragmentResult](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentResultOwner#setFragmentResult(java.lang.String,android.os.Bundle))`(requestKey: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, result: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`)` Sets the given result for the requestKey.                                                                                                                                                                                                                                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setFragmentResultListener](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentResultOwner#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener))`(` ` requestKey: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` lifecycleOwner: `[LifecycleOwner](https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner)`,` ` listener: `[FragmentResultListener](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentResultListener) `)` Sets the[FragmentResultListener](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentResultListener)for a given requestKey. |

## Public functions

### clearFragmentResult

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

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|---------------------------------|
| `requestKey: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | key used to identify the result |

### clearFragmentResultListener

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

```
fun clearFragmentResultListener(requestKey: String): Unit
```

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

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|---------------------------------|
| `requestKey: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | key used to identify the result |

### setFragmentResult

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

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|---------------------------------------------|
| `requestKey: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | key used to identify the result             |
| `result: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)              | 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)  

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

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

|                                                            Parameters                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|
| `requestKey: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                   | requestKey used to identify the result |
| `lifecycleOwner: `[LifecycleOwner](https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner)              | lifecycleOwner for handling the result |
| `listener: `[FragmentResultListener](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentResultListener) | listener for result changes            |