# 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)

*** ** * ** ***


```
class CustomAudience.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/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)( buyer: https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, dailyUpdateUri: https://developer.android.com/reference/android/net/Uri.html, biddingLogicUri: https://developer.android.com/reference/android/net/Uri.html, ads: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdData> )` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#build()()` Builds an instance of a `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience`. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setActivationTime(java.time.Instant)(activationTime: https://developer.android.com/reference/java/time/Instant.html)` On creation of the `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` object, an optional activation time may be set in the future, in order to serve a delayed activation. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setAds(kotlin.collections.List)(ads: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdData>)` This list of `https://developer.android.com/reference/kotlin/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/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` during the ad selection process. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `@https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/ExperimentalFeatures.Ext14OptIn https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setAuctionServerRequestFlags(kotlin.Int)(auctionServerRequestFlag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the bitfield of auction server request flags. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setBiddingLogicUri(android.net.Uri)(biddingLogicUri: https://developer.android.com/reference/android/net/Uri.html)` Returns the target URI used to fetch bidding logic when a custom audience participates in the ad selection process. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setBuyer(androidx.privacysandbox.ads.adservices.common.AdTechIdentifier)(buyer: https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier)` Sets the buyer `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier`. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setDailyUpdateUri(android.net.Uri)(dailyUpdateUri: https://developer.android.com/reference/android/net/Uri.html)` 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. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setExpirationTime(java.time.Instant)(expirationTime: https://developer.android.com/reference/java/time/Instant.html)` 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. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setName(kotlin.String)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience` object's name. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `@https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/ExperimentalFeatures.Ext14OptIn https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setPriority(kotlin.Double)(priority: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)` Sets the priority for this CustomAudience with respect to other CustomAudiences for this buyer. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setTrustedBiddingData(androidx.privacysandbox.ads.adservices.customaudience.TrustedBiddingData)(trustedBiddingSignals: https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/TrustedBiddingData)` 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. |
| `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder` | `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience.Builder#setUserBiddingSignals(androidx.privacysandbox.ads.adservices.common.AdSelectionSignals)(userBiddingSignals: https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdSelectionSignals)` 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)

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

## Public functions

### build

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

```
fun build(): CustomAudience
```

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

### setActivationTime

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

```
fun setActivationTime(activationTime: Instant): CustomAudience.Builder
```

On creation of the `https://developer.android.com/reference/kotlin/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/kotlin/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 |
|---|---|
| `activationTime: https://developer.android.com/reference/java/time/Instant.html` | activation time, truncated to milliseconds, after which the `https://developer.android.com/reference/kotlin/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)

```
fun setAds(ads: List<AdData>): CustomAudience.Builder
```

This list of `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/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 |
|---|---|
| `ads: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdData>` | a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` of `https://developer.android.com/reference/kotlin/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
fun setAuctionServerRequestFlags(auctionServerRequestFlag: Int): CustomAudience.Builder
```

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 |
|---|---|
| `auctionServerRequestFlag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | 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)

```
fun setBiddingLogicUri(biddingLogicUri: Uri): CustomAudience.Builder
```

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 |
|---|---|
| `biddingLogicUri: https://developer.android.com/reference/android/net/Uri.html` | 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)

```
fun setBuyer(buyer: AdTechIdentifier): CustomAudience.Builder
```

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

| Parameters |
|---|---|
| `buyer: https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdTechIdentifier` | 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)

```
fun setDailyUpdateUri(dailyUpdateUri: Uri): CustomAudience.Builder
```

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 |
|---|---|
| `dailyUpdateUri: https://developer.android.com/reference/android/net/Uri.html` | 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)

```
fun setExpirationTime(expirationTime: Instant): CustomAudience.Builder
```

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/kotlin/androidx/privacysandbox/ads/adservices/customaudience/CustomAudience`, expiry will default to 60 days from activation.

The maximum expiry is 60 days from initial activation.

| Parameters |
|---|---|
| `expirationTime: https://developer.android.com/reference/java/time/Instant.html` | 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)

```
fun setName(name: String): CustomAudience.Builder
```

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

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The custom audience's name is an arbitrary string provided by the owner and buyer on creation of the `https://developer.android.com/reference/kotlin/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
fun setPriority(priority: Double): CustomAudience.Builder
```

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 |
|---|---|
| `priority: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | 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)

```
fun setTrustedBiddingData(trustedBiddingSignals: TrustedBiddingData): CustomAudience.Builder
```

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/kotlin/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 |
|---|---|
| `trustedBiddingSignals: https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/customaudience/TrustedBiddingData` | a `https://developer.android.com/reference/kotlin/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)

```
fun setUserBiddingSignals(userBiddingSignals: AdSelectionSignals): CustomAudience.Builder
```

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/kotlin/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 |
|---|---|
| `userBiddingSignals: https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdSelectionSignals` | an `https://developer.android.com/reference/kotlin/androidx/privacysandbox/ads/adservices/common/AdSelectionSignals` object representing the user bidding signals for the custom audience |