使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
AdServicesOutcomeReceiver
public
interface
AdServicesOutcomeReceiver
回调接口,适用于异步操作可能导致失败的情况。该接口是 OutcomeReceiver
类的精确副本,可在 AdServices 软件包中重新定义以实现对 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 和/或其关联公司的注册商标。
最后更新时间 (UTC):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"]],["最后更新时间 (UTC):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 |"]]