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 | |
|---|---|
| 
        
        
        
        
        
        void | 
      fetchAndJoinCustomAudience(FetchAndJoinCustomAudienceRequest fetchAndJoinCustomAudienceRequest, Executor executor, OutcomeReceiver<Object, Exception> receiver)
      Adds the user to the  | 
| 
        
        
        static
        
        
        CustomAudienceManager | 
      get(Context context)
      Factory method for creating an instance of CustomAudienceManager. | 
| 
        
        
        
        
        
        TestCustomAudienceManager | 
      getTestCustomAudienceManager()
      Create a service with test-enabling APIs | 
| 
        
        
        
        
        
        void | 
      joinCustomAudience(JoinCustomAudienceRequest joinCustomAudienceRequest, Executor executor, OutcomeReceiver<Object, Exception> receiver)
      Adds the user to the given  | 
| 
        
        
        
        
        
        void | 
      leaveCustomAudience(LeaveCustomAudienceRequest leaveCustomAudienceRequest, Executor executor, OutcomeReceiver<Object, Exception> receiver)
      Attempts to remove a user from a custom audience by deleting any existing  | 
| Inherited methods | |
|---|---|
Public methods
fetchAndJoinCustomAudience
public void fetchAndJoinCustomAudience (FetchAndJoinCustomAudienceRequest fetchAndJoinCustomAudienceRequest, Executor executor, OutcomeReceiver<Object, Exception> receiver)
Adds the user to the CustomAudience fetched from a fetchUri.
 
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
 
- the ownerPackageNameis not calling app's package name and/or
- the buyer is not authorized to use the API.
This call fails with an IllegalArgumentException if
 
- the storage limit has been exceeded by the calling application and/or
- any URI parameters in the CustomAudiencegiven are not authenticated with theCustomAudiencebuyer.
This call fails with LimitExceededException if the calling package exceeds the
 allowed rate limits and is throttled.
 
This call fails with an IllegalStateException if an internal service error is
 encountered.
 
 
 Requires AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE
| Parameters | |
|---|---|
| fetchAndJoinCustomAudienceRequest | FetchAndJoinCustomAudienceRequest: This value cannot benull. | 
| executor | Executor: This value cannot benull.
 
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| receiver | OutcomeReceiver: This value cannot benull. | 
get
public static CustomAudienceManager get (Context context)
Factory method for creating an instance of CustomAudienceManager.
| Parameters | |
|---|---|
| context | Context: TheContextto use
 This value cannot benull. | 
| Returns | |
|---|---|
| CustomAudienceManager | A CustomAudienceManagerinstance
 
 This value cannot benull. | 
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<Object, Exception> 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
 
- the ownerPackageNameis not calling app's package name and/or
- the buyer is not authorized to use the API.
This call fails with an IllegalArgumentException if
 
- the storage limit has been exceeded by the calling application and/or
- any URI parameters in the CustomAudiencegiven are not authenticated with theCustomAudiencebuyer.
This call fails with LimitExceededException if the calling package exceeds the
 allowed rate limits and is throttled.
 
This call fails with an IllegalStateException if an internal service error is
 encountered.
 
 
 Requires AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE
| Parameters | |
|---|---|
| joinCustomAudienceRequest | JoinCustomAudienceRequest: This value cannot benull. | 
| executor | Executor: This value cannot benull.
 
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| receiver | OutcomeReceiver: This value cannot benull. | 
leaveCustomAudience
public void leaveCustomAudience (LeaveCustomAudienceRequest leaveCustomAudienceRequest, Executor executor, OutcomeReceiver<Object, Exception> 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
 
- the ownerPackageNameis not calling app's package name; and/or
- the buyer is not authorized to use the API.
This call fails with LimitExceededException if the calling package exceeds the
 allowed rate limits and is throttled.
 
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.
 
 
 Requires AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE
| Parameters | |
|---|---|
| leaveCustomAudienceRequest | LeaveCustomAudienceRequest: This value cannot benull. | 
| executor | Executor: This value cannot benull.
 
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| receiver | OutcomeReceiver: This value cannot benull. | 
