Stay organized with collections
Save and categorize content based on your preferences.
OutcomeReceiver
public
interface
OutcomeReceiver
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 |
default
void
|
onError(E error)
Called when the asynchronous operation fails.
|
abstract
void
|
onResult(R result)
Called when the asynchronous operation succeeds and delivers a result value.
|
Public methods
onError
public void onError (E error)
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
public abstract void onResult (R result)
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# OutcomeReceiver\n\nAdded in [API level 31](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nOutcomeReceiver\n===============\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/os/OutcomeReceiver \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nOutcomeReceiver\n`\n\n\n`\n\n\n`\n\n|--------------------------------------------------------------------------------------------------|\n| android.os.OutcomeReceiver\\\u003cR, E extends [java.lang.Throwable](/reference/java/lang/Throwable)\\\u003e |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nCallback interface intended for use when an asynchronous operation may result in a failure.\n\nThis interface may be used in cases where an asynchronous API may complete either with a value\nor with a [Throwable](/reference/java/lang/Throwable) that indicates an error.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` default void` | ` `[onError](/reference/android/os/OutcomeReceiver#onError(E))`(E error) ` Called when the asynchronous operation fails. |\n| ` abstract void` | ` `[onResult](/reference/android/os/OutcomeReceiver#onResult(R))`(R result) ` Called when the asynchronous operation succeeds and delivers a result value. |\n\nPublic methods\n--------------\n\n### onError\n\nAdded in [API level 31](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void onError (E error)\n```\n\nCalled when the asynchronous operation fails. The mode of failure is indicated by the\n[Throwable](/reference/java/lang/Throwable) passed as an argument to this method.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `error` | `E`: A subclass of [Throwable](/reference/java/lang/Throwable) with more details about the error that occurred. This value cannot be `null`. \u003cbr /\u003e |\n\n### onResult\n\nAdded in [API level 31](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onResult (R result)\n```\n\nCalled when the asynchronous operation succeeds and delivers a result value.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------|----------------------------------------------------------------|\n| `result` | `R`: The value delivered by the asynchronous operation. \u003cbr /\u003e |"]]