Перейти к консоли

AdRequest.Builder

public static final class AdRequest.Builder extends Object

Builds an AdRequest.

Public Constructor Summary

Public Method Summary

AdRequest.Builder
addCustomEventExtrasBundle(Class<? extends CustomEvent> adapterClass, Bundle customEventExtras)
Add extra parameters to pass to a specific custom event adapter.
AdRequest.Builder
addKeyword(String keyword)
Add a keyword for targeting purposes.
AdRequest.Builder
addNetworkExtras(NetworkExtras networkExtras)
Add extra parameters to pass to a specific ad network adapter.
AdRequest.Builder
addNetworkExtrasBundle(Class<? extends MediationExtrasReceiver> adapterClass, Bundle networkExtras)
Add extra parameters to pass to a specific ad network adapter.
AdRequest.Builder
addTestDevice(String deviceId)
Causes a device to receive test ads.
AdRequest
build()
Constructs an AdRequest with the specified attributes.
AdRequest.Builder
setBirthday(Date birthday)
This method is deprecated. No replacement.
AdRequest.Builder
setContentUrl(String contentUrl)
Sets the content URL for targeting purposes.
AdRequest.Builder
setGender(int gender)
This method is deprecated. No replacement.
AdRequest.Builder
setIsDesignedForFamilies(boolean isDesignedForFamilies)
This method is deprecated. Use Ad Content Filtering.
AdRequest.Builder
setLocation(Location location)
Sets the user's location for targeting purposes.
AdRequest.Builder
setMaxAdContentRating(String maxAdContentRating)
This method is deprecated. See setMaxAdContentRating(String)
AdRequest.Builder
setRequestAgent(String requestAgent)
Sets the request agent string to identify the ad request's origin.
AdRequest.Builder
setTagForUnderAgeOfConsent(int tagForUnderAgeOfConsent)
This method is deprecated. See setTagForUnderAgeOfConsent(int)
AdRequest.Builder
tagForChildDirectedTreatment(boolean tagForChildDirectedTreatment)
This method is deprecated. See setTagForChildDirectedTreatment(int)

Inherited Method Summary

Public Constructors

public AdRequest.Builder ()

Public Methods

public AdRequest.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 AdRequest.Builder addKeyword (String keyword)

Add a keyword for targeting purposes.

public AdRequest.Builder addNetworkExtras (NetworkExtras networkExtras)

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

Note that the NetworkExtras class has been deprecated. This method is included to maintain compatibility with older adapters.

public AdRequest.Builder addNetworkExtrasBundle (Class<? extends MediationExtrasReceiver> adapterClass, Bundle networkExtras)

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

Parameters
adapterClass The Class of the adapter that should receive extras.
networkExtras A Bundle of extra information to pass to a mediation adapter.

public AdRequest.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.

This method should only be used while debugging. Be sure to remove all calls to this method before releasing your app.

public AdRequest build ()

Constructs an AdRequest with the specified attributes.

public AdRequest.Builder setBirthday (Date birthday)

This method is deprecated.
No replacement.

Sets the user's birthday for targeting purposes.

public AdRequest.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 AdRequest.Builder setGender (int gender)

This method is deprecated.
No replacement.

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

public AdRequest.Builder setIsDesignedForFamilies (boolean isDesignedForFamilies)

This method is deprecated.
Use Ad Content Filtering.

This method allows apps that have opted into the Designed for Families program to specify whether a given ad request should return Designed for Families-compliant ads. Please note that the method is ONLY intended for apps that have opted into Designed for Families. Please see the Google AdMob help center article for more information about this setting.

If you set this value to true, you indicate that your app requires that the ad request should return a Designed for Families-compliant ad.

If you set this value to false, you indicate that your app does not require that the ad request should return a Designed for Families-compliant ad.

Note: This setting is separate from the Children's Online Privacy Protection Act (COPPA) "tag for child directed treatment" setting. For COPPA-related compliance, see tagForChildDirectedTreatment(boolean).

public AdRequest.Builder setLocation (Location location)

Sets the user's location for targeting purposes.

public AdRequest.Builder setMaxAdContentRating (String maxAdContentRating)

This method is deprecated.
See setMaxAdContentRating(String)

Set a maximum ad content rating. AdMob ads returned for these requests have a content rating at or below that level. Valid values are MAX_AD_CONTENT_RATING_G, MAX_AD_CONTENT_RATING_PG, MAX_AD_CONTENT_RATING_T, and MAX_AD_CONTENT_RATING_MA.

public AdRequest.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