public static final class

SearchAdRequest.Builder

extends Object
java.lang.Object
   ↳ com.google.android.gms.ads.search.SearchAdRequest.Builder

Class Overview

Builds a SearchAdRequest.

Summary

Public Constructors
SearchAdRequest.Builder()
Public Methods
SearchAdRequest.Builder addCustomEventExtrasBundle(Class<? extends CustomEvent> adapterClass, Bundle customEventExtras)
Add extra parameters to pass to a specific custom event adapter.
SearchAdRequest.Builder addNetworkExtras(NetworkExtras networkExtras)
Add extra parameters to pass to a specific ad network adapter.
SearchAdRequest.Builder addNetworkExtrasBundle(Class<? extends MediationAdapter> adapterClass, Bundle networkExtras)
Add extra parameters to pass to a specific ad network adapter.
SearchAdRequest.Builder addTestDevice(String deviceId)
Causes a device to receive test ads.
SearchAdRequest build()
Constructs a SearchAdRequest with the specified attributes.
SearchAdRequest.Builder setAnchorTextColor(int anchorTextColor)
Sets the color of the ad URL.
SearchAdRequest.Builder setBackgroundColor(int backgroundColor)
Sets the background color of the ad.
SearchAdRequest.Builder setBackgroundGradient(int top, int bottom)
Sets a gradient for the ad background.
SearchAdRequest.Builder setBorderColor(int borderColor)
Sets the border color of the ad container.
SearchAdRequest.Builder setBorderThickness(int borderThickness)
Sets the thickness of the border in pixels around the ad container.
SearchAdRequest.Builder setBorderType(int borderType)
Sets the type of border around the ad container.
SearchAdRequest.Builder setCallButtonColor(int callButtonColor)
Sets the color of the call button when a call extension is shown.
SearchAdRequest.Builder setCustomChannels(String channelIds)
Sets custom channels for the ad request.
SearchAdRequest.Builder setDescriptionTextColor(int descriptionTextColor)
Sets the color of the ad description.
SearchAdRequest.Builder setFontFace(String fontFace)
Sets the font used to render the ad.
SearchAdRequest.Builder setHeaderTextColor(int headerTextColor)
Sets the text color of the ad header.
SearchAdRequest.Builder setHeaderTextSize(int headerTextSize)
Sets the font size of the header text in pixels.
SearchAdRequest.Builder setLocation(Location location)
Sets the user's location for targeting purposes.
SearchAdRequest.Builder setQuery(String query)
Sets the query for requesting a search ad.
SearchAdRequest.Builder setRequestAgent(String requestAgent)
Sets the request agent string to identify the ad request's origin.
SearchAdRequest.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 SearchAdRequest.Builder ()

Public Methods

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

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

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

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

Parameters
networkExtras NetworkExtras
Returns
SearchAdRequest.Builder

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

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

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

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

Parameters
deviceId String
Returns
SearchAdRequest.Builder

public SearchAdRequest build ()

Constructs a SearchAdRequest with the specified attributes.

Returns
SearchAdRequest

public SearchAdRequest.Builder setAnchorTextColor (int anchorTextColor)

Sets the color of the ad URL. Transparency is not supported. rgb(int, int, int) can be used to specify this color.

Parameters
anchorTextColor int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setBackgroundColor (int backgroundColor)

Sets the background color of the ad. Calling this method will override any previous calls to setBackgroundColor(int) or setBackgroundGradient(int, int). Transparency is not supported. rgb(int, int, int) can be used to specify this color.

Parameters
backgroundColor int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setBackgroundGradient (int top, int bottom)

Sets a gradient for the ad background. Calling this method will override any previous calls to setBackgroundColor(int) or setBackgroundGradient(int, int). Transparency is not supported. rgb(int, int, int) can be used to specify these colors.

Parameters
top int: The color of the gradient at the top of the ad.
bottom int: The color of the gradient at the bottom of the ad.
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setBorderColor (int borderColor)

Sets the border color of the ad container. Transparency is not supported. rgb(int, int, int) can be used to specify this color. This setting is ignored if setBorderType(int) is set to BORDER_TYPE_NONE.

Parameters
borderColor int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setBorderThickness (int borderThickness)

Sets the thickness of the border in pixels around the ad container. This setting is ignored if setBorderType(int) is set to BORDER_TYPE_NONE.

Parameters
borderThickness int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setBorderType (int borderType)

Sets the type of border around the ad container. This value must be one of BORDER_TYPE_NONE, BORDER_TYPE_DASHED, BORDER_TYPE_DOTTED, BORDER_TYPE_SOLID.

Parameters
borderType int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setCallButtonColor (int callButtonColor)

Sets the color of the call button when a call extension is shown. This value must be one of CALL_BUTTON_COLOR_DARK, CALL_BUTTON_COLOR_LIGHT, CALL_BUTTON_COLOR_MEDIUM.

Parameters
callButtonColor int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setCustomChannels (String channelIds)

Sets custom channels for the ad request. Custom channels allow publishers to track the performance of specific groups of ads. These custom channels need to created on the AdSense website. Reports can then be created based on the channels.

Parameters
channelIds String: A list of channel IDs separated by '+'.
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setDescriptionTextColor (int descriptionTextColor)

Sets the color of the ad description. Transparency is not supported. rgb(int, int, int) can be used to specify this color.

Parameters
descriptionTextColor int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setFontFace (String fontFace)

Sets the font used to render the ad. The same font is used in the header, the description and the anchor. Fonts are specified using the same value that would be used in CSS (e.g., "arial").

Parameters
fontFace String
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setHeaderTextColor (int headerTextColor)

Sets the text color of the ad header. Transparency is not supported. rgb(int, int, int) can be used to specify this color.

Parameters
headerTextColor int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setHeaderTextSize (int headerTextSize)

Sets the font size of the header text in pixels. The font sizes for the description and the anchor are determined from the header size.

Parameters
headerTextSize int
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setLocation (Location location)

Sets the user's location for targeting purposes.

Parameters
location Location
Returns
SearchAdRequest.Builder

public SearchAdRequest.Builder setQuery (String query)

Sets the query for requesting a search ad. The query must be set to receive an ad.

Parameters
query String
Returns
SearchAdRequest.Builder

public SearchAdRequest.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".

Parameters
requestAgent String
Returns
SearchAdRequest.Builder

public SearchAdRequest.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 boolean: 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.
Returns
SearchAdRequest.Builder