透過集合功能整理內容
你可以依據偏好儲存及分類內容。
AdServicesOutcomeReceiver
public
interface
AdServicesOutcomeReceiver
非同步作業可能失敗時使用的回呼介面。相當於 AdServices 套件中重新定義的 OutcomeReceiver
類別,可回溯相容於 Android R。
如果非同步 API 完成時會傳回值,或傳回代表錯誤的 Throwable
,這個介面就能派上用場。
摘要
公用方法 |
default
void
|
onError(E error)
非同步作業失敗時呼叫的方法。
|
abstract
void
|
onResult(R result)
非同步作業成功並提交結果值時呼叫的方法。
|
公用方法
onError
public void onError (E error)
非同步作業失敗時呼叫的方法。失敗模式是由做為引數傳遞至此方法的 Throwable
指定。
參數 |
error |
E :Throwable 的子類別,提供發生錯誤的詳細情形。
此值不能為 null 。 |
onResult
public abstract void onResult (R result)
非同步作業成功並提交結果值時呼叫的方法。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# AdServicesOutcomeReceiver\n\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \n\nAdServicesOutcomeReceiver\n=========================\n\n\n`\npublic\n\n\ninterface\nAdServicesOutcomeReceiver\n`\n\n\n`\n\n\n`\n\n|---------------------------------------------------------------------------------------------------------------------------|\n| android.adservices.common.AdServicesOutcomeReceiver\\\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. Exact\ncopy of the [OutcomeReceiver](/reference/android/os/OutcomeReceiver) class, re-defined in the AdServices package for\nbackwards compatibility to Android R.\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](/design-for-safety/privacy-sandbox/reference/adservices/common/AdServicesOutcomeReceiver#onError(E))`(E error) ` Called when the asynchronous operation fails. |\n| ` abstract void` | ` `[onResult](/design-for-safety/privacy-sandbox/reference/adservices/common/AdServicesOutcomeReceiver#onResult(R))`(R result) ` Called when the asynchronous operation succeeds and delivers a result value. |\n\nPublic methods\n--------------\n\n### onError\n\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \n\n```\npublic void onError (E error)\n```\n\nCalled when the asynchronous operation fails. The mode of failure is indicated by the [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\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \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 |"]]