AdRequest

public class AdRequest

Known direct subclasses
BannerAdRequest

A banner ad request.

IconAdRequest

An AdRequest for IconAds.

NativeAdRequest

A native ad request.


An AdRequest contains targeting information used to fetch an ad. Ad requests are created using AdRequest.Builder.

Summary

Nested types

public final class AdRequest.Builder

Builder class for AdRequest.

@IntDef(value = [0, 1, 2, 3, 4, 5, 6])
@Retention(value = AnnotationRetention.SOURCE)
public annotation AdRequest.ErrorCode

Protected constructors

AdRequest(
    @NonNull String adUnitId,
    @NonNull Set<@NonNull String> categoryExclusions,
    String contentUrl,
    @NonNull Map<@NonNull String, @NonNull String> customTargeting,
    @NonNull Bundle googleExtrasBundle,
    @NonNull Set<@NonNull String> keywords,
    @NonNull Set<@NonNull String> neighboringContentUrls,
    @NonNull Map<@NonNull String, @NonNull Bundle> adSourceExtrasBundles,
    String publisherProvidedId,
    String requestAgent,
    long placementId,
    boolean skipUninitializedAdapters
)

Public methods

final Bundle

Gets the extras bundle associated with an ad source's adapter, if present.

@NonNull String

The ad unit ID.

final @NonNull Set<@NonNull String>

The slot-level ad category exclusion labels.

final String

The content URL targeting information.

final @NonNull Map<@NonNull String, @NonNull String>

The custom targeting parameters.

final @NonNull Bundle

The extra parameters to pass to Google ad network

final @NonNull Set<@NonNull String>

The targeting information keywords.

final @NonNull Set<@NonNull String>

The list of neighboring content URLs or an empty List if no URLs were set.

final long

An identifier for a placement in reporting.

final String

A publisher-provided identifier used for frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.

final String

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

Protected constructors

AdRequest

protected AdRequest(
    @NonNull String adUnitId,
    @NonNull Set<@NonNull String> categoryExclusions,
    String contentUrl,
    @NonNull Map<@NonNull String, @NonNull String> customTargeting,
    @NonNull Bundle googleExtrasBundle,
    @NonNull Set<@NonNull String> keywords,
    @NonNull Set<@NonNull String> neighboringContentUrls,
    @NonNull Map<@NonNull String, @NonNull Bundle> adSourceExtrasBundles,
    String publisherProvidedId,
    String requestAgent,
    long placementId,
    boolean skipUninitializedAdapters
)

Public methods

getAdSourceExtrasBundle

public final Bundle getAdSourceExtrasBundle(
    @NonNull Class<@NonNull MediationExtrasReceiver> adapterClass
)

Gets the extras bundle associated with an ad source's adapter, if present.

getAdUnitId

public @NonNull String getAdUnitId()

The ad unit ID.

getCategoryExclusions

public final @NonNull Set<@NonNull StringgetCategoryExclusions()

The slot-level ad category exclusion labels. Default to an empty Set if not set.

getContentUrl

public final String getContentUrl()

The content URL targeting information. Default to null if not set.

getCustomTargeting

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

The custom targeting parameters. Default to an empty Map if not set.

getGoogleExtrasBundle

public final @NonNull Bundle getGoogleExtrasBundle()

The extra parameters to pass to Google ad network

getKeywords

public final @NonNull Set<@NonNull StringgetKeywords()

The targeting information keywords.

getNeighboringContentUrls

public final @NonNull Set<@NonNull StringgetNeighboringContentUrls()

The list of neighboring content URLs or an empty List if no URLs were set.

getPlacementId

public final long getPlacementId()

An identifier for a placement in reporting. A value set here will be set onto any ad returned by this request.

getPublisherProvidedId

public final String getPublisherProvidedId()

A publisher-provided identifier used for frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.

getRequestAgent

public final String getRequestAgent()

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