# OutcomeReceiver

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

# OutcomeReceiver

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver "View this page in Kotlin")\|Java

`
public


interface
OutcomeReceiver
`  
`


`

|------------------------------------------------------------------------------------------------------------------------------|
| android.os.OutcomeReceiver\<R, E extends[java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable)\> |

<br />

*** ** * ** ***

Callback interface intended for use when an asynchronous operation may result in a failure. This interface may be used in cases where an asynchronous API may complete either with a value or with a[Throwable](https://developer.android.com/reference/java/lang/Throwable)that indicates an error.

## Summary

|                                                                                            ### Public methods                                                                                             ||
|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` default void`  | ` `[onError](https://developer.android.com/reference/android/os/OutcomeReceiver#onError(E))`(E error) ` Called when the asynchronous operation fails.                                   |
| ` abstract void` | ` `[onResult](https://developer.android.com/reference/android/os/OutcomeReceiver#onResult(R))`(R result) ` Called when the asynchronous operation succeeds and delivers a result value. |

## Public methods

### onError

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void onError (E error)
```

Called when the asynchronous operation fails. The mode of failure is indicated by the[Throwable](https://developer.android.com/reference/java/lang/Throwable)passed as an argument to this method.

<br />

|                                                                                       Parameters                                                                                       ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `error` | `E`: A subclass of[Throwable](https://developer.android.com/reference/java/lang/Throwable)with more details about the error that occurred. This value cannot be`null`. <br /> |

### onResult

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void onResult (R result)
```

Called when the asynchronous operation succeeds and delivers a result value.

<br />

|                                Parameters                                ||
|----------|----------------------------------------------------------------|
| `result` | `R`: The value delivered by the asynchronous operation. <br /> |