AppOpenAdRequest.Builder

class AppOpenAdRequest.Builder


A builder for an AppOpenAdRequest.

Summary

Public constructors

Builder(adUnitId: String)

Public functions

AppOpenAdRequest.Builder

Sets a slot-level ad category exclusion label.

AppOpenAdRequest.Builder

Adds a keyword for targeting purposes.

AppOpenAdRequest

Constructs an AppOpenAdRequest with the specified attributes.

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

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

AppOpenAdRequest.Builder

Adds a custom targeting parameter.

AppOpenAdRequest.Builder

Adds a custom targeting parameter with multiple values.

AppOpenAdRequest.Builder

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

AppOpenAdRequest.Builder

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

AppOpenAdRequest.Builder

Set extra parameters to pass to AdMob or Ad Manager.

AppOpenAdRequest.Builder

Sets URLs representing web content near an ad.

open AppOpenAdRequest.Builder

Sets a default placement ID for the loaded ad.

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.

AppOpenAdRequest.Builder

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

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

Builder(adUnitId: String)

Public functions

addCategoryExclusion

@CanIgnoreReturnValue
fun addCategoryExclusion(categoryExclusion: String): AppOpenAdRequest.Builder

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
fun addKeyword(keyword: String): AppOpenAdRequest.Builder

Adds a keyword for targeting purposes.

build

fun build(): AppOpenAdRequest

Constructs an AppOpenAdRequest with the specified attributes.

putAdSourceExtrasBundle

@CanIgnoreReturnValue
fun putAdSourceExtrasBundle(
    adapterClass: Class<MediationExtrasReceiver>,
    adSourceExtras: Bundle
): AppOpenAdRequest.Builder

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

Parameters
adapterClass: Class<MediationExtrasReceiver>

The Class of the adapter that should receive extras.

adSourceExtras: Bundle

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

putCustomTargeting

@CanIgnoreReturnValue
fun putCustomTargeting(key: String, value: String): AppOpenAdRequest.Builder

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
fun putCustomTargeting(key: String, values: List<String>): AppOpenAdRequest.Builder

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
fun setAdPersistenceEnabled(): AppOpenAdRequest.Builder

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
fun setContentUrl(contentUrl: String): AppOpenAdRequest.Builder

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
fun setGoogleExtrasBundle(extraBundle: Bundle): AppOpenAdRequest.Builder

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

Parameters
extraBundle: Bundle

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

setNeighboringContentUrls

@CanIgnoreReturnValue
fun setNeighboringContentUrls(neighboringContentUrls: Set<String>): AppOpenAdRequest.Builder

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
neighboringContentUrls: Set<String>

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

setPlacementId

@CanIgnoreReturnValue
open fun setPlacementId(placementId: Long): AppOpenAdRequest.Builder

Sets a default placement ID for the loaded ad.

Parameters
placementId: Long

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

setPublisherProvidedId

@CanIgnoreReturnValue
fun setPublisherProvidedId(publisherProvidedId: String): 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.

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

setRequestAgent

@CanIgnoreReturnValue
fun setRequestAgent(requestAgent: String): AppOpenAdRequest.Builder

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
fun skipUninitializedAdapters(): AppOpenAdRequest.Builder

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

Protected functions

getContentUrl

protected fun getContentUrl(): String?

getGoogleExtrasBundle

protected fun getGoogleExtrasBundle(): Bundle

getPlacementId

protected fun getPlacementId(): Long

getPublisherProvidedId

protected fun getPublisherProvidedId(): String?

getRequestAgent

protected fun getRequestAgent(): String?

getSkipUninitializedAdapters

protected fun getSkipUninitializedAdapters(): Boolean

self

protected open fun self(): AppOpenAdRequest.Builder

Protected properties

adSourceExtrasBundles

protected val adSourceExtrasBundlesMutableMap<StringBundle>

adUnitId

protected var adUnitIdString?

The ad unit ID.

categoryExclusions

protected val categoryExclusionsMutableSet<String>

customTargeting

protected val customTargetingMutableMap<StringString>

keywords

protected val keywordsHashSet<String>

neighboringContentUrls

protected val neighboringContentUrlsHashSet<String>