# CustomAudience.Builder

Artifact: [androidx.privacysandbox.ads:ads-adservices](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads) [View Source](https://cs.android.com/search?q=file:androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.kt+class:androidx.privacysandbox.ads.adservices.customaudience.CustomAudience.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

*** ** * ** ***


```
public final class CustomAudience.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` objects.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#Builder(androidx.privacysandbox.ads.adservices.common.AdTechIdentifier,kotlin.String,android.net.Uri,android.net.Uri,kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier buyer, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html dailyUpdateUri, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html biddingLogicUri, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdData> ads )` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#build()()` Builds an instance of a `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setActivationTime(java.time.Instant)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html activationTime)` On creation of the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` object, an optional activation time may be set in the future, in order to serve a delayed activation. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setAds(kotlin.collections.List)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdData> ads)` This list of `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdData` objects is a full and complete list of the ads that will be served by this `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` during the ad selection process. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `@https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/ExperimentalFeatures.Ext14OptIn https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setAuctionServerRequestFlags(kotlin.Int)(int auctionServerRequestFlag)` Returns the bitfield of auction server request flags. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setBiddingLogicUri(android.net.Uri)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html biddingLogicUri)` Returns the target URI used to fetch bidding logic when a custom audience participates in the ad selection process. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setBuyer(androidx.privacysandbox.ads.adservices.common.AdTechIdentifier)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier buyer)` Sets the buyer `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setDailyUpdateUri(android.net.Uri)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html dailyUpdateUri)` This URI points to a buyer-operated server that hosts updated bidding data and ads metadata to be used in the on-device ad selection process. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setExpirationTime(java.time.Instant)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html expirationTime)` Once the expiration time has passed, a custom audience is no longer eligible for daily ad/bidding data updates or participation in the ad selection process. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setName(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name)` Sets the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` object's name. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `@https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/ExperimentalFeatures.Ext14OptIn https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setPriority(kotlin.Double)(double priority)` Sets the priority for this CustomAudience with respect to other CustomAudiences for this buyer. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setTrustedBiddingData(androidx.privacysandbox.ads.adservices.customaudience.TrustedBiddingData)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/TrustedBiddingData trustedBiddingSignals)` Trusted bidding data consists of a URI pointing to a trusted server for buyers' bidding data and a list of keys to query the server with. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setUserBiddingSignals(androidx.privacysandbox.ads.adservices.common.AdSelectionSignals)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdSelectionSignals userBiddingSignals)` User bidding signals are optionally provided by buyers to be consumed by buyer-provided JavaScript during ad selection in an isolated execution environment. |

## Public constructors

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public Builder(
    @NonNull AdTechIdentifier buyer,
    @NonNull String name,
    @NonNull Uri dailyUpdateUri,
    @NonNull Uri biddingLogicUri,
    @NonNull List<@NonNull AdData> ads
)
```

## Public methods

### build

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience build()
```

Builds an instance of a `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience`.

### setActivationTime

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setActivationTime(@NonNull Instant activationTime)
```

On creation of the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` object, an optional activation time may be set in the future, in order to serve a delayed activation. If the field is not set, the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` will be activated at the time of joining.

For example, a custom audience for lapsed users may not activate until a threshold of inactivity is reached, at which point the custom audience's ads will participate in the ad selection process, potentially redirecting lapsed users to the original owner application.

The maximum delay in activation is 60 days from initial creation.

If specified, the activation time must be an earlier instant than the expiration time.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html activationTime` | activation time, truncated to milliseconds, after which the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` will serve ads. |

### setAds

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setAds(@NonNull List<@NonNull AdData> ads)
```

This list of `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdData` objects is a full and complete list of the ads that will be served by this `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` during the ad selection process.

If not specified, or if an empty list is provided, the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` will not participate in ad selection until a valid list of ads are provided via the daily update for the custom audience.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdData> ads` | a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` of `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdData` objects representing ads currently served by the custom audience. |

### setAuctionServerRequestFlags

Added in [1.1.0-beta12](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.1.0-beta12)

```
@ExperimentalFeatures.Ext14OptIn
public final @NonNull CustomAudience.Builder setAuctionServerRequestFlags(int auctionServerRequestFlag)
```

Returns the bitfield of auction server request flags. These are flags that influence the creation of the payload generated by the {@link android.adservices.adselection.AdSelectionManager#getAdSelectionData(GetAdSelectionDataRequest, Executor, OutcomeReceiver)} API.

To create this bitfield, place an {@code \|} bitwise operator between each {@link
AuctionServerRequestFlag} to be enabled.

| Parameters |
|---|---|
| `int auctionServerRequestFlag` | a `https://developer.android.com/reference/java/lang/Integer.html` representing the auction server request flag. Value is either `0` or a combination of the following: - `0` - `1` <br /> |

### setBiddingLogicUri

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setBiddingLogicUri(@NonNull Uri biddingLogicUri)
```

Returns the target URI used to fetch bidding logic when a custom audience participates in the ad selection process. The URI must use HTTPS.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html biddingLogicUri` | the URI for fetching buyer bidding logic |

### setBuyer

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setBuyer(@NonNull AdTechIdentifier buyer)
```

Sets the buyer `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier buyer` | A buyer is identified by a domain in the form "buyerexample.com". |

### setDailyUpdateUri

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setDailyUpdateUri(@NonNull Uri dailyUpdateUri)
```

This URI points to a buyer-operated server that hosts updated bidding data and ads metadata to be used in the on-device ad selection process. The URI must use HTTPS.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html dailyUpdateUri` | the custom audience's daily update URI |

### setExpirationTime

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setExpirationTime(@NonNull Instant expirationTime)
```

Once the expiration time has passed, a custom audience is no longer eligible for daily ad/bidding data updates or participation in the ad selection process. The custom audience will then be deleted from memory by the next daily update.

If no expiration time is provided on creation of the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience`, expiry will default to 60 days from activation.

The maximum expiry is 60 days from initial activation.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html expirationTime` | the timestamp `https://developer.android.com/reference/java/time/Instant.html`, truncated to milliseconds, after which the custom audience should be removed. |

### setName

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setName(@NonNull String name)
```

Sets the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` object's name.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | The custom audience's name is an arbitrary string provided by the owner and buyer on creation of the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` object. |

### setPriority

Added in [1.1.0-beta12](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.1.0-beta12)

```
@ExperimentalFeatures.Ext14OptIn
public final @NonNull CustomAudience.Builder setPriority(double priority)
```

Sets the priority for this CustomAudience with respect to other CustomAudiences for this buyer.

This means if there is insufficient space during buyer input generation in the {@link
android.adservices.adselection.AdSelectionManager#getAdSelectionData(GetAdSelectionDataRequest,
Executor, OutcomeReceiver)} call, the service will attempt to include the highest
priority custom audiences first.

The default value if this field is not set is 0.0.

| Parameters |
|---|---|
| `double priority` | a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` representing the priority of this custom audience. |

### setTrustedBiddingData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setTrustedBiddingData(@NonNull TrustedBiddingData trustedBiddingSignals)
```

Trusted bidding data consists of a URI pointing to a trusted server for buyers' bidding data and a list of keys to query the server with. Note that the keys are arbitrary identifiers that will only be used to query the trusted server for a buyer's bidding logic during ad selection.

If not specified, the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` will not participate in ad selection until trusted bidding data are provided via the daily update for the custom audience.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/TrustedBiddingData trustedBiddingSignals` | a `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/TrustedBiddingData` object containing the custom audience's trusted bidding data. |

### setUserBiddingSignals

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public final @NonNull CustomAudience.Builder setUserBiddingSignals(@NonNull AdSelectionSignals userBiddingSignals)
```

User bidding signals are optionally provided by buyers to be consumed by buyer-provided JavaScript during ad selection in an isolated execution environment.

If the user bidding signals are not a valid JSON object that can be consumed by the buyer's JS, the custom audience will not be eligible for ad selection.

If not specified, the `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` will not participate in ad selection until user bidding signals are provided via the daily update for the custom audience.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdSelectionSignals userBiddingSignals` | an `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/AdSelectionSignals` object representing the user bidding signals for the custom audience |