Summary: Nested Classes | Constants | Fields | Methods | Inherited Methods | [Expand All]
public final class

# PublisherAdRequest

extends Object

java.lang.Object
↳ | com.google.android.gms.ads.doubleclick.PublisherAdRequest

## Class Overview

A `PublisherAdRequest` contains targeting information used to fetch an ad from DoubleClick for Publishers. Ad requests are created using `PublisherAdRequest.Builder`.

## Summary

Nested Classes
class | PublisherAdRequest.Builder | Builds a `PublisherAdRequest`.

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.
String | getContentUrl() Returns the content url targeting information.
<T extends CustomEvent> Bundle | getCustomEventExtrasBundle(Class<T> adapterClass) Returns extra parameters to pass to a specific custom event adapter.
Bundle | getCustomTargeting() Returns the custom targeting parameters.
int | getGender() Returns the user's gender targeting information.
Set<String> | getKeywords() Returns targeting information keywords.
Location | getLocation() Returns the user's location targeting information.
boolean | getManualImpressionsEnabled() Returns `true` if manual impression reporting is enabled.
<T extends NetworkExtras> T | getNetworkExtras(Class<T> networkExtrasClass) Returns extra parameters to pass to a specific ad network adapter.
<T extends MediationAdapter> Bundle | getNetworkExtrasBundle(Class<T> adapterClass) Returns extra parameters to pass to a specific ad network adapter.
String | getPublisherProvidedId() Returns the identifier used for frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.
boolean | isTestDevice(Context context) Returns `true` if this device will receive test ads.
static void | updateCorrelator() Changes the correlator that is sent with ad requests, effectively starting a new page view.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## 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 String getContentUrl ()

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

#### public Bundle 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.

#### public Bundle getCustomTargeting ()

Returns the custom targeting parameters.

#### 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 Location getLocation ()

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

#### public boolean getManualImpressionsEnabled ()

Returns `true` if manual impression reporting is enabled.

#### 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 Bundle 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.

#### public String getPublisherProvidedId ()

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

#### public boolean isTestDevice (Context context)

Returns `true` if this device will receive test ads.

#### public static void updateCorrelator ()

Changes the correlator that is sent with ad requests, effectively starting a new page view. The correlator is the same for all the ad requests coming from one page view, and unique across page views. After updating the correlator, ads must be refreshed for the new correlator to take effect.