Stay organized with collections Save and categorize content based on your preferences.

CustomAudienceManager

public class CustomAudienceManager
extends Object

java.lang.Object
   ↳ android.adservices.customaudience.CustomAudienceManager


CustomAudienceManager provides APIs for app and ad-SDKs to join / leave custom audiences.

Summary

Public methods

TestCustomAudienceManager getTestCustomAudienceManager()

Create a service with test-enabling APIs

void joinCustomAudience(JoinCustomAudienceRequest joinCustomAudienceRequest, Executor executor, OutcomeReceiver<ObjectException> receiver)

Adds the user to the given CustomAudience.

void leaveCustomAudience(LeaveCustomAudienceRequest leaveCustomAudienceRequest, Executor executor, OutcomeReceiver<ObjectException> receiver)

Attempts to remove a user from a custom audience by deleting any existing CustomAudience data, identified by ownerPackageName, buyer, and name.

Inherited methods

Public methods

getTestCustomAudienceManager

public TestCustomAudienceManager getTestCustomAudienceManager ()

Create a service with test-enabling APIs

Returns
TestCustomAudienceManager This value cannot be null.

joinCustomAudience

public void joinCustomAudience (JoinCustomAudienceRequest joinCustomAudienceRequest, 
                Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

Adds the user to the given CustomAudience.

An attempt to register the user for a custom audience with the same combination of ownerPackageName, buyer, and name will cause the existing custom audience's information to be overwritten, including the list of ads data.

Note that the ads list can be completely overwritten by the daily background fetch job.

This call fails with an SecurityException if

  1. the ownerPackageName is not calling app's package name and/or
  2. the buyer is not authorized to use the API.

This call fails with an IllegalArgumentException if

  1. the storage limit has been exceeded by the calling application and/or
  2. any URL parameters in the CustomAudience given are not authenticated with the CustomAudience buyer.

This call fails with an IllegalStateException if an internal service error is encountered.

Parameters
joinCustomAudienceRequest JoinCustomAudienceRequest: This value cannot be null.

executor Executor: This value cannot be null.
receiver OutcomeReceiver: This value cannot be null.

leaveCustomAudience

public void leaveCustomAudience (LeaveCustomAudienceRequest leaveCustomAudienceRequest, 
                Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

Attempts to remove a user from a custom audience by deleting any existing CustomAudience data, identified by ownerPackageName, buyer, and name.

This call fails with an SecurityException if

  1. the ownerPackageName is not calling app's package name; and/or
  2. the buyer is not authorized to use the API.

This call does not inform the caller whether the custom audience specified existed in on-device storage. In other words, it will fail silently when a buyer attempts to leave a custom audience that was not joined.

Parameters
leaveCustomAudienceRequest LeaveCustomAudienceRequest: This value cannot be null.

executor Executor: This value cannot be null.
receiver OutcomeReceiver: This value cannot be null.