Stay organized with collections
Save and categorize content based on your preferences.
OutcomeReceiver
interface OutcomeReceiver<R : Any!, E : Throwable!>
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
that indicates an error.
Summary
Public methods |
open Unit |
Called when the asynchronous operation fails.
|
abstract Unit |
Called when the asynchronous operation succeeds and delivers a result value.
|
Public methods
onError
open fun onError(error: E): Unit
Called when the asynchronous operation fails. The mode of failure is indicated by the Throwable
passed as an argument to this method.
Parameters |
error |
E: A subclass of Throwable with more details about the error that occurred. This value cannot be null . |
onResult
abstract fun onResult(result: R): Unit
Called when the asynchronous operation succeeds and delivers a result value.
Parameters |
result |
R: The value delivered by the asynchronous operation. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# OutcomeReceiver\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOutcomeReceiver\n===============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/os/OutcomeReceiver \"View this page in Java\") \n\n```\ninterface OutcomeReceiver\u003cR : Any!, E : Throwable!\u003e\n```\n\n|---------------------------------|\n| [android.os.OutcomeReceiver](#) |\n\nCallback 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](../../java/lang/Throwable.html#) that indicates an error.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onError](#onError(android.os.OutcomeReceiver.E))`(`error:` `E`)` Called when the asynchronous operation fails. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onResult](#onResult(android.os.OutcomeReceiver.R))`(`result:` `R`)` Called when the asynchronous operation succeeds and delivers a result value. |\n\nPublic methods\n--------------\n\n### onError\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onError(error: E): Unit\n```\n\nCalled when the asynchronous operation fails. The mode of failure is indicated by the [Throwable](../../java/lang/Throwable.html#) passed as an argument to this method.\n\n| Parameters ||\n|---------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| `error` | E: A subclass of [Throwable](../../java/lang/Throwable.html#) with more details about the error that occurred. This value cannot be `null`. |\n\n### onResult\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onResult(result: R): Unit\n```\n\nCalled when the asynchronous operation succeeds and delivers a result value.\n\n| Parameters ||\n|----------|-------------------------------------------------------|\n| `result` | R: The value delivered by the asynchronous operation. |"]]