AdRequest

public class AdRequest 
Known direct subclasses

An AdManagerAdRequest contains targeting information used to fetch an ad from Google Ad Manager.


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

Publishers using Ad Manager should use com.google.android.gms.ads.admanager.AdManagerAdRequest .

Summary

Nested types

Builds an AdRequest .

Constants

static final String
DEVICE_ID_EMULATOR = "B3EEABB8EE11C2BE770B684D95219ECB"

The deviceId for emulators to be used with setTestDeviceIds .

static final int

The ad request was not made due to a missing app ID.

static final int

Something happened internally; for instance, an invalid response was received from the ad server.

static final int

The ad string is invalid.

static final int

The ad request was invalid; for instance, the ad unit ID was incorrect.

static final int

The mediation adapter did not fill the ad request.

static final int

The ad request was unsuccessful due to network connectivity.

static final int

The ad request was successful, but no ad was returned due to lack of ad inventory.

static final int

The request ID in the ad string is not found.

static final int

The maximum content URL length.

Public methods

@ Nullable String

Gets the ad string.

String

Returns the content URL targeting information.

@ Nullable Bundle
<T extends  CustomEvent > getCustomEventExtrasBundle ( Class <T> adapterClass)

This method is deprecated.

Use getNetworkExtrasBundle instead.

Set < String >

Returns targeting information keywords.

List < String >

Returns the list of neighboring content URLs or an empty list if no URLs were set.

@ Nullable Bundle
<T extends  MediationExtrasReceiver > getNetworkExtrasBundle (
Class <T> adapterClass
)

Returns extra parameters to pass to a specific ad network adapter.

long

Gets the placement ID set in this AdRequest

String

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

boolean
isTestDevice ( Context  context)

Returns true if this device will receive test ads.

Constants

DEVICE_ID_EMULATOR

public static final  String 
 DEVICE_ID_EMULATOR 
= "B3EEABB8EE11C2BE770B684D95219ECB"

The deviceId for emulators to be used with setTestDeviceIds .

ERROR_CODE_APP_ID_MISSING

public static final int  ERROR_CODE_APP_ID_MISSING 
= 8

The ad request was not made due to a missing app ID.

ERROR_CODE_INTERNAL_ERROR

public static final int  ERROR_CODE_INTERNAL_ERROR 
= 0

Something happened internally; for instance, an invalid response was received from the ad server.

ERROR_CODE_INVALID_AD_STRING

public static final int  ERROR_CODE_INVALID_AD_STRING 
= 11

The ad string is invalid. For example, there is no request ID in the ad string.

ERROR_CODE_INVALID_REQUEST

public static final int  ERROR_CODE_INVALID_REQUEST 
= 1

The ad request was invalid; for instance, the ad unit ID was incorrect.

ERROR_CODE_MEDIATION_NO_FILL

public static final int  ERROR_CODE_MEDIATION_NO_FILL 
= 9

The mediation adapter did not fill the ad request. If this error is returned from getCode , check getCause for the underlying cause.

ERROR_CODE_NETWORK_ERROR

public static final int  ERROR_CODE_NETWORK_ERROR 
= 2

The ad request was unsuccessful due to network connectivity.

ERROR_CODE_NO_FILL

public static final int  ERROR_CODE_NO_FILL 
= 3

The ad request was successful, but no ad was returned due to lack of ad inventory.

ERROR_CODE_REQUEST_ID_MISMATCH

public static final int  ERROR_CODE_REQUEST_ID_MISMATCH 
= 10

The request ID in the ad string is not found.

MAX_CONTENT_URL_LENGTH

public static final int  MAX_CONTENT_URL_LENGTH 
= 512

The maximum content URL length.

Public methods

getAdString

public @ Nullable 
 String 
 getAdString 
()

Gets the ad string.

getContentUrl

public  String 
 getContentUrl 
()

Returns the content URL targeting information. Returns null if the contentUrl was not set.

getCustomEventExtrasBundle

public @ Nullable 
 Bundle 
 <T extends  CustomEvent 
>   getCustomEventExtrasBundle 
 
 
( Class 
<T> adapterClass)

Returns extra parameters to pass to a specific custom event adapter. Returns null if no custom event extras of the provided type were set.

getKeywords

public  Set 
< String 
 getKeywords 
()

Returns targeting information keywords. Returns an empty Set if no keywords were added.

getNeighboringContentUrls

public  List 
< String 
 getNeighboringContentUrls 
()

Returns the list of neighboring content URLs or an empty list if no URLs were set.

getNetworkExtrasBundle

public @ Nullable 
 Bundle 
 <T extends  MediationExtrasReceiver 
> getNetworkExtrasBundle 
(
Class <T> adapterClass
)

Returns extra parameters to pass to a specific ad network adapter. Returns null if no network extras of the provided type were set.

getPlacementId

public long  getPlacementId 
()

Gets the placement ID set in this AdRequest

getRequestAgent

public  String 
 getRequestAgent 
()

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

isTestDevice

public boolean  isTestDevice 
( Context 
 context)

Returns true if this device will receive test ads.

Design a Mobile Site
View Site in Mobile | Classic
Share by: