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

public SearchAdRequest build ()

Constructs a SearchAdRequest with the specified attributes.

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.

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.

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 The color of the gradient at the top of the ad.
bottom The color of the gradient at the bottom of the ad.

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.

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.

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.

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.

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 A list of channel IDs separated by '+'.

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.

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").

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.

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.

public SearchAdRequest.Builder setLocation (Location location)

Sets the user's location for targeting purposes.

public SearchAdRequest.Builder setQuery (String query)

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

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