AppOpenAdRequest.Builder

public final class AppOpenAdRequest.Builder


A builder for an AppOpenAdRequest.

Summary

Public constructors

Builder(@NonNull String adUnitId)

Public methods

final @NonNull AppOpenAdRequest.Builder

Sets a slot-level ad category exclusion label.

final @NonNull AppOpenAdRequest.Builder

Adds a keyword for targeting purposes.

final @NonNull AppOpenAdRequest

Constructs an AppOpenAdRequest with the specified attributes.

final @NonNull AppOpenAdRequest.Builder

Adds extra parameters to pass to a specific ad source adapter.

final @NonNull AppOpenAdRequest.Builder

Adds a custom targeting parameter.

final @NonNull AppOpenAdRequest.Builder

Adds a custom targeting parameter with multiple values.

final @NonNull AppOpenAdRequest.Builder

Enables the SDK to utilize on-disk persistence to improve load latency for this AppOpenAdRequest.

final @NonNull AppOpenAdRequest.Builder

Sets the content URL for a web site whose content matches the app's primary content.

final @NonNull AppOpenAdRequest.Builder

Set extra parameters to pass to AdMob or Ad Manager.

final @NonNull AppOpenAdRequest.Builder

Sets URLs representing web content near an ad.

@NonNull AppOpenAdRequest.Builder

Sets a default placement ID for the loaded ad.

final @NonNull AppOpenAdRequest.Builder

Sets an identifier for use in frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.

final @NonNull AppOpenAdRequest.Builder

Sets the request agent string to identify the ad request's origin.

final @NonNull AppOpenAdRequest.Builder

Instructs the SDK to not collect bidding signals or execute waterfall elements for adapters that have not yet successfully initialized.

Public constructors

Builder

public Builder(@NonNull String adUnitId)

Public methods

addCategoryExclusion

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder addCategoryExclusion(@NonNull String categoryExclusion)

Sets a slot-level ad category exclusion label.

This feature is only applicable for Ad Manager ad requests. Any category exclusions will be ignored on AdMob requests.

addKeyword

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder addKeyword(@NonNull String keyword)

Adds a keyword for targeting purposes.

build

public final @NonNull AppOpenAdRequest build()

Constructs an AppOpenAdRequest with the specified attributes.

putAdSourceExtrasBundle

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder putAdSourceExtrasBundle(
    @NonNull Class<@NonNull MediationExtrasReceiver> adapterClass,
    @NonNull Bundle adSourceExtras
)

Adds extra parameters to pass to a specific ad source adapter.

Parameters
@NonNull Class<@NonNull MediationExtrasReceiver> adapterClass

The Class of the adapter that should receive extras.

@NonNull Bundle adSourceExtras

A Bundle of extra information to pass to a mediation adapter.

putCustomTargeting

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder putCustomTargeting(@NonNull String key, @NonNull String value)

Adds a custom targeting parameter. Calling this a second time with the same key will overwrite the old values.

This feature is only applicable for Ad Manager ad requests. Any custom targeting will be ignored on AdMob requests.

putCustomTargeting

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder putCustomTargeting(
    @NonNull String key,
    @NonNull List<@NonNull String> values
)

Adds a custom targeting parameter with multiple values. Calling this a second time with the same key will overwrite the old values.

This feature is only applicable for Ad Manager ad requests. AdMob requests currently ignore custom targeting.

setAdPersistenceEnabled

@ExperimentalApi
@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder setAdPersistenceEnabled()

Enables the SDK to utilize on-disk persistence to improve load latency for this AppOpenAdRequest.

Enabling this feature allows the SDK to attempt to retrieve a valid ad from local storage before falling back to a standard network request. When enabled, this feature introduces two distinct behavior changes to the ad loading process:

  1. Cache-First Retrieval: The SDK attempts to serve an ad from local storage first. If the cache is empty, it falls back to a network request.

  2. Proactive Refresh: Regardless of how the current ad was served, the SDK fetches additional ads and persists them to local storage to service the next request.

Available for allowlisted accounts only. Reach out to your account manager for more information.

setContentUrl

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder setContentUrl(@NonNull String contentUrl)

Sets the content URL for a web site whose content matches the app's primary content. This web site content is used for targeting and brand safety purposes.

Throws
kotlin.IllegalArgumentException

If contentUrl is empty.

setGoogleExtrasBundle

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder setGoogleExtrasBundle(@NonNull Bundle extraBundle)

Set extra parameters to pass to AdMob or Ad Manager. Calling this a second time will overwrite the old values.

Parameters
@NonNull Bundle extraBundle

A Bundle of extra information to pass to AdMob or Ad Manager.

setNeighboringContentUrls

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder setNeighboringContentUrls(
    @NonNull Set<@NonNull String> neighboringContentUrls
)

Sets URLs representing web content near an ad. Promotes brand safety and allows displayed ads to have an app level rating (MA, T, PG, etc) that is more appropriate to neighboring content.

Parameters
@NonNull Set<@NonNull String> neighboringContentUrls

The set of neighboring content URLs to be attached to the existing neighboring content URLs.

setPlacementId

@CanIgnoreReturnValue
public @NonNull AppOpenAdRequest.Builder setPlacementId(long placementId)

Sets a default placement ID for the loaded ad.

Parameters
long placementId

A long integer provided by the AdMob UI for the configured placement.

setPublisherProvidedId

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder setPublisherProvidedId(@NonNull String publisherProvidedId)

Sets an identifier for use in frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.

This feature is only applicable for Ad Manager ad requests. Any ID will be ignored on AdMob requests.

setRequestAgent

@CanIgnoreReturnValue
public final @NonNull AppOpenAdRequest.Builder setRequestAgent(@NonNull String requestAgent)

Sets the request agent string to identify the ad request's origin. Third party libraries that implement the Mobile Ads SDK on behalf of publishers should call this method to denote the platform from which the ad request originated.

skipUninitializedAdapters

@ExperimentalApi
public final @NonNull AppOpenAdRequest.Builder skipUninitializedAdapters()

Instructs the SDK to not collect bidding signals or execute waterfall elements for adapters that have not yet successfully initialized.

Protected methods

getAdSourceExtrasBundles

protected final @NonNull Map<@NonNull String, @NonNull BundlegetAdSourceExtrasBundles()

getAdUnitId

protected final String getAdUnitId()

The ad unit ID.

getCategoryExclusions

protected final @NonNull Set<@NonNull StringgetCategoryExclusions()

getContentUrl

protected final String getContentUrl()

getCustomTargeting

protected final @NonNull Map<@NonNull String, @NonNull StringgetCustomTargeting()

getGoogleExtrasBundle

protected final @NonNull Bundle getGoogleExtrasBundle()

getKeywords

protected final @NonNull HashSet<@NonNull StringgetKeywords()

getNeighboringContentUrls

protected final @NonNull HashSet<@NonNull StringgetNeighboringContentUrls()

getPlacementId

protected final long getPlacementId()

getPublisherProvidedId

protected final String getPublisherProvidedId()

getRequestAgent

protected final String getRequestAgent()

getSkipUninitializedAdapters

protected final boolean getSkipUninitializedAdapters()

self

protected @NonNull AppOpenAdRequest.Builder self()

setAdUnitId

protected final void setAdUnitId(String adUnitId)

The ad unit ID.