AdSelectionManager
public
class
AdSelectionManager
extends Object
| java.lang.Object | |
| ↳ | android.adservices.adselection.AdSelectionManager |
AdSelection Manager provides APIs for app and ad-SDKs to run ad selection processes as well as report impressions.
Summary
Public methods | |
|---|---|
TestAdSelectionManager
|
getTestAdSelectionManager()
|
void
|
reportImpression(ReportImpressionRequest request, Executor executor, OutcomeReceiver<Object, Exception> receiver)
Report the given impression. |
void
|
selectAds(AdSelectionConfig adSelectionConfig, Executor executor, OutcomeReceiver<AdSelectionOutcome, Exception> receiver)
Runs the ad selection process on device to select a remarketing ad for the caller application. |
void
|
selectAds(AdSelectionFromOutcomesConfig adSelectionFromOutcomesConfig, Executor executor, OutcomeReceiver<AdSelectionOutcome, Exception> receiver)
Selects an ad from the results of previously ran ad selections. |
Inherited methods | |
|---|---|
Public methods
getTestAdSelectionManager
public TestAdSelectionManager getTestAdSelectionManager ()
| Returns | |
|---|---|
TestAdSelectionManager |
This value cannot be null. |
reportImpression
public void reportImpression (ReportImpressionRequest request, Executor executor, OutcomeReceiver<Object, Exception> receiver)
Report the given impression. The ReportImpressionRequest is provided by the Ads SDK.
The receiver either returns a void for a successful run, or an Exception
indicates the error.
Requires AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE
| Parameters | |
|---|---|
request |
ReportImpressionRequest: This value cannot be null. |
executor |
Executor: This value cannot be null. |
receiver |
OutcomeReceiver: This value cannot be null. |
selectAds
public void selectAds (AdSelectionConfig adSelectionConfig, Executor executor, OutcomeReceiver<AdSelectionOutcome, Exception> receiver)
Runs the ad selection process on device to select a remarketing ad for the caller application.
The input adSelectionConfig is provided by the Ads SDK and the AdSelectionConfig object is transferred via a Binder call. For this reason, the total size
of these objects is bound to the Android IPC limitations. Failures to transfer the AdSelectionConfig will throws an TransactionTooLargeException.
The output is passed by the receiver, which either returns an AdSelectionOutcome
for a successful run, or an Exception includes the type of the exception thrown and
the corresponding error message.
If the IllegalArgumentException is thrown, it is caused by invalid input argument
the API received to run the ad selection.
If the IllegalStateException is thrown with error message "Failure of AdSelection
services.", it is caused by an internal failure of the ad selection service.
If the TimeoutException is thrown, it is caused when a timeout is encountered
during bidding, scoring, or overall selection process to find winning Ad.
If the LimitExceededException is thrown, it is caused when the calling package
exceeds the allowed rate limits and is throttled.
If the SecurityException is thrown, it is caused when the caller is not authorized
or permission is not requested.
Requires AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE
| Parameters | |
|---|---|
adSelectionConfig |
AdSelectionConfig: This value cannot be null. |
executor |
Executor: This value cannot be null.
Callback and listener events are dispatched through this
Executor, providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor().
Otherwise, provide an Executor that dispatches to an appropriate thread. |
receiver |
OutcomeReceiver: This value cannot be null. |
selectAds
public void selectAds (AdSelectionFromOutcomesConfig adSelectionFromOutcomesConfig, Executor executor, OutcomeReceiver<AdSelectionOutcome, Exception> receiver)
Selects an ad from the results of previously ran ad selections.
The input adSelectionFromOutcomesConfig is provided by the Ads SDK and the AdSelectionFromOutcomesConfig object is transferred via a Binder call. For this reason, the
total size of these objects is bound to the Android IPC limitations. Failures to transfer the
AdSelectionFromOutcomesConfig will throws an TransactionTooLargeException.
The output is passed by the receiver, which either returns an AdSelectionOutcome
for a successful run, or an Exception includes the type of the exception thrown and
the corresponding error message.
The input adSelectionFromOutcomesConfig contains:
Selleris required to be a registeredAdTechIdentifier. Otherwise,IllegalStateExceptionwill be thrown.List of ad selection idsshould exist and come fromselectAds(AdSelectionConfig, Executor, OutcomeReceivercalls originated from the same application. Otherwise,) IllegalArgumentExceptionfor input validation will raise listing violating ad selection ids.Selection logic URIshould match thesellerhost. Otherwise,IllegalArgumentExceptionwill be thrown.
If the IllegalArgumentException is thrown, it is caused by invalid input argument
the API received to run the ad selection.
If the IllegalStateException is thrown with error message "Failure of AdSelection
services.", it is caused by an internal failure of the ad selection service.
If the TimeoutException is thrown, it is caused when a timeout is encountered
during bidding, scoring, or overall selection process to find winning Ad.
If the LimitExceededException is thrown, it is caused when the calling package
exceeds the allowed rate limits and is throttled.
If the SecurityException is thrown, it is caused when the caller is not authorized
or permission is not requested.
Requires AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE
| Parameters | |
|---|---|
adSelectionFromOutcomesConfig |
AdSelectionFromOutcomesConfig: This value cannot be null. |
executor |
Executor: This value cannot be null.
Callback and listener events are dispatched through this
Executor, providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor().
Otherwise, provide an Executor that dispatches to an appropriate thread. |
receiver |
OutcomeReceiver: This value cannot be null. |