public final class

AdRequest

extends Object
java.lang.Object
   ↳ com.google.android.gms.ads.AdRequest

Class Overview

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

Summary

Nested Classes
class AdRequest.Builder Builds an AdRequest
Constants
int ERROR_CODE_INTERNAL_ERROR Something happened internally; for instance, an invalid response was received from the ad server.
int ERROR_CODE_INVALID_REQUEST The ad request was invalid; for instance, the ad unit ID was incorrect.
int ERROR_CODE_NETWORK_ERROR The ad request was unsuccessful due to network connectivity.
int ERROR_CODE_NO_FILL The ad request was successful, but no ad was returned due to lack of ad inventory.
int GENDER_FEMALE Female gender.
int GENDER_MALE Male gender.
int GENDER_UNKNOWN Unknown gender.
Fields
public static final String DEVICE_ID_EMULATOR The deviceId for emulators to be used with addTestDevice(String).
Public Methods
Date getBirthday()
Returns the user's birthday targeting information.
int getGender()
Returns the user's gender targeting information.
Set<String> getKeywords()
Returns targeting information keywords.
<T extends NetworkExtras> T getNetworkExtras(Class<T> networkExtrasClass)
Returns extra parameters to pass to a specific ad network adapter.
boolean isTestDevice(Context context)
Returns true if this device will receive test ads.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ERROR_CODE_INTERNAL_ERROR

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

Constant Value: 0 (0x00000000)

public static final int ERROR_CODE_INVALID_REQUEST

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

Constant Value: 1 (0x00000001)

public static final int ERROR_CODE_NETWORK_ERROR

The ad request was unsuccessful due to network connectivity.

Constant Value: 2 (0x00000002)

public static final int ERROR_CODE_NO_FILL

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

Constant Value: 3 (0x00000003)

public static final int GENDER_FEMALE

Female gender.

Constant Value: 2 (0x00000002)

public static final int GENDER_MALE

Male gender.

Constant Value: 1 (0x00000001)

public static final int GENDER_UNKNOWN

Unknown gender.

Constant Value: 0 (0x00000000)

Fields

public static final String DEVICE_ID_EMULATOR

The deviceId for emulators to be used with addTestDevice(String).

Public Methods

public Date getBirthday ()

Returns the user's birthday targeting information. Returns null if the birthday was not set.

public int getGender ()

Returns the user's gender targeting information. Returns -1 if the gender was not set.

public Set<String> getKeywords ()

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

public T getNetworkExtras (Class<T> networkExtrasClass)

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

public boolean isTestDevice (Context context)

Returns true if this device will receive test ads.