public static final class

PublisherAdRequest.Builder

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

Class Overview

Builds a PublisherAdRequest.

Summary

Public Constructors
PublisherAdRequest.Builder()
Public Methods
PublisherAdRequest.Builder addCategoryExclusion(String categoryExclusion)
Sets a slot-level ad category exclusion label.
PublisherAdRequest.Builder addCustomEventExtrasBundle(Class<? extends CustomEvent> adapterClass, Bundle customEventExtras)
Add extra parameters to pass to a specific custom event adapter.
PublisherAdRequest.Builder addCustomTargeting(String key, String value)
Adds a custom targeting parameter.
PublisherAdRequest.Builder addCustomTargeting(String key, List<String> values)
Adds a custom targeting parameter.
PublisherAdRequest.Builder addKeyword(String keyword)
Add a keyword for targeting purposes.
PublisherAdRequest.Builder addNetworkExtras(NetworkExtras networkExtras)
Add extra parameters to pass to a specific ad network adapter.
PublisherAdRequest.Builder addNetworkExtrasBundle(Class<? extends MediationAdapter> adapterClass, Bundle networkExtras)
Add extra parameters to pass to a specific ad network adapter.
PublisherAdRequest.Builder addTestDevice(String deviceId)
Causes a device to receive test ads.
PublisherAdRequest build()
Constructs PublisherAdRequest with the specified attributes.
PublisherAdRequest.Builder setBirthday(Date birthday)
Sets the user's birthday for targeting purposes.
PublisherAdRequest.Builder setContentUrl(String contentUrl)
Sets the content URL for targeting purposes.
PublisherAdRequest.Builder setGender(int gender)
Sets the user's gender for targeting purposes.
PublisherAdRequest.Builder setLocation(Location location)
Sets the user's location for targeting purposes.
PublisherAdRequest.Builder setManualImpressionsEnabled(boolean manualImpressionsEnabled)
Enables manual impression reporting.
PublisherAdRequest.Builder setPublisherProvidedId(String publisherProvidedId)
Sets an identifier for use in frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.
PublisherAdRequest.Builder setRequestAgent(String requestAgent)
Sets the request agent string to identify the ad request's origin.
PublisherAdRequest.Builder tagForChildDirectedTreatment(boolean tagForChildDirectedTreatment)
This method allows you to specify whether you would like your app to be treated as child-directed for purposes of the Children’s Online Privacy Protection Act (COPPA) - http://business.ftc.gov/privacy-and-security/childrens-privacy.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PublisherAdRequest.Builder ()

Public Methods

public PublisherAdRequest.Builder addCategoryExclusion (String categoryExclusion)

Sets a slot-level ad category exclusion label.

public PublisherAdRequest.Builder addCustomEventExtrasBundle (Class<? extends CustomEvent> adapterClass, Bundle customEventExtras)

Add extra parameters to pass to a specific custom event adapter.

Parameters
adapterClass The Class of the custom event adapter for which you are providing extras.
customEventExtras A Bundle of extra information to pass to a custom event adapter.

public PublisherAdRequest.Builder addCustomTargeting (String key, String value)

Adds a custom targeting parameter. Calling this multiple times for the same key will overwrite old values.

public PublisherAdRequest.Builder addCustomTargeting (String key, List<String> values)

Adds a custom targeting parameter. Calling this multiple times for the same key will overwrite old values.

public PublisherAdRequest.Builder addKeyword (String keyword)

Add a keyword for targeting purposes.

public PublisherAdRequest.Builder addNetworkExtras (NetworkExtras networkExtras)

Add extra parameters to pass to a specific ad network adapter. networkExtras should be an instance of com.google.ads.mediation.NetworkExtras, which is provided by ad network adapters.

public PublisherAdRequest.Builder addNetworkExtrasBundle (Class<? extends MediationAdapter> adapterClass, Bundle networkExtras)

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

Parameters
adapterClass The Class of the adapter for the network for which you are providing extras.
networkExtras A Bundle of extra information to pass to a mediation adapter.

public PublisherAdRequest.Builder addTestDevice (String deviceId)

Causes a device to receive test ads. The deviceId can be obtained by viewing the logcat output after creating a new ad. For emulators, use DEVICE_ID_EMULATOR.

public PublisherAdRequest build ()

Constructs PublisherAdRequest with the specified attributes.

public PublisherAdRequest.Builder setBirthday (Date birthday)

Sets the user's birthday for targeting purposes.

public PublisherAdRequest.Builder setContentUrl (String contentUrl)

Sets the content URL for targeting purposes.

Throws
NullPointerException If contentUrl is {code null}.
IllegalArgumentException If contentUrl is empty, or if its length exceeds 512.

public PublisherAdRequest.Builder setGender (int gender)

Sets the user's gender for targeting purposes. This should be GENDER_MALE, GENDER_FEMALE, or GENDER_UNKNOWN.

public PublisherAdRequest.Builder setLocation (Location location)

Sets the user's location for targeting purposes.

public PublisherAdRequest.Builder setManualImpressionsEnabled (boolean manualImpressionsEnabled)

Enables manual impression reporting.

public PublisherAdRequest.Builder setPublisherProvidedId (String publisherProvidedId)

Sets an identifier for use in frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.

public PublisherAdRequest.Builder setRequestAgent (String requestAgent)

Sets the request agent string to identify the ad request's origin. Third party libraries that reference the Mobile Ads SDK should call this method to denote the platform from which the ad request originated. For example, if a third party ad network called "CoolAds network" mediates requests to the Mobile Ads SDK, it should call this method with "CoolAds".

public PublisherAdRequest.Builder tagForChildDirectedTreatment (boolean tagForChildDirectedTreatment)

This method allows you to specify whether you would like your app to be treated as child-directed for purposes of the Children’s Online Privacy Protection Act (COPPA) - http://business.ftc.gov/privacy-and-security/childrens-privacy.

If you set this method to true, you will indicate that your app should be treated as child-directed for purposes of the Children’s Online Privacy Protection Act (COPPA).

If you set this method to false, you will indicate that your app should not be treated as child-directed for purposes of the Children’s Online Privacy Protection Act (COPPA).

If you do not set this method, ad requests will include no indication of how you would like your app treated with respect to COPPA.

By setting this method, you certify that this notification is accurate and you are authorized to act on behalf of the owner of the app. You understand that abuse of this setting may result in termination of your Google account.

Note: it may take some time for this designation to be fully implemented in applicable Google services.

This designation will only apply to ad requests for which you have set this method.

Parameters
tagForChildDirectedTreatment Set to true to indicate that your app should be treated as child-directed. Set to false to indicate that your app should not be treated as child-directed.