SearchAdRequest | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

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

# SearchAdRequest

extends Object

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

## Class Overview

A `SearchAdRequest` contains targeting information used to fetch an ad from Search Ads for Apps. Ad requests are created using `SearchAdRequest.Builder`.

## Summary

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

Constants
int | BORDER_TYPE_DASHED | Dashed border.
int | BORDER_TYPE_DOTTED | Dotted border.
int | BORDER_TYPE_NONE | No border.
int | BORDER_TYPE_SOLID | Solid border.
int | CALL_BUTTON_COLOR_DARK | Dark-colored call button.
int | CALL_BUTTON_COLOR_LIGHT | Light-colored call button.
int | CALL_BUTTON_COLOR_MEDIUM | Medium-colored call button.
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.

Fields
public static final String | DEVICE_ID_EMULATOR | The `deviceId` for emulators to be used with `addTestDevice(String)`.

Public Methods
int | getAnchorTextColor() Returns the color of the ad URL.
int | getBackgroundColor() Returns the background color of the ad.
int | getBackgroundGradientBottom() Returns the color of the background gradient at the bottom of the ad.
int | getBackgroundGradientTop() Returns the color of the background gradient at the top of the ad.
int | getBorderColor() Returns the border color of the ad container.
int | getBorderThickness() Returns the thickness of the border in pixels around the ad container.
int | getBorderType() Returns the type of border around the ad container.
int | getCallButtonColor() Returns the color of the call button when a call extension is shown.
String | getCustomChannels() Returns the custom channels for the ad request.
<T extends CustomEvent> Bundle | getCustomEventExtrasBundle(Class<T> adapterClass) Returns extra parameters to pass to a specific custom event adapter.
int | getDescriptionTextColor() Returns the color of the ad description.
String | getFontFace() Returns the font used to render the ad.
int | getHeaderTextColor() Returns the font size of the header text in pixels.
int | getHeaderTextSize() Returns the font size of the header text in pixels.
Location | getLocation() Returns the user's location targeting information.
<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 | getQuery() Returns the query of the search ad request.
boolean | isTestDevice(Context context) Returns `true` if this device will receive test ads.

[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()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

## Constants

#### public static final int BORDER_TYPE_DASHED

Dashed border.

Constant Value: 1 (0x00000001)

#### public static final int BORDER_TYPE_DOTTED

Dotted border.

Constant Value: 2 (0x00000002)

#### public static final int BORDER_TYPE_NONE

No border.

Constant Value: 0 (0x00000000)

#### public static final int BORDER_TYPE_SOLID

Solid border.

Constant Value: 3 (0x00000003)

#### public static final int CALL_BUTTON_COLOR_DARK

Dark-colored call button.

Constant Value: 2 (0x00000002)

#### public static final int CALL_BUTTON_COLOR_LIGHT

Light-colored call button.

Constant Value: 0 (0x00000000)

#### public static final int CALL_BUTTON_COLOR_MEDIUM

Medium-colored call button.

Constant Value: 1 (0x00000001)

#### 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)

## Fields

#### public static final String DEVICE_ID_EMULATOR

The `deviceId` for emulators to be used with `addTestDevice(String)`.

## Public Methods

#### public int getAnchorTextColor ()

Returns the color of the ad URL.

#### public int getBackgroundColor ()

Returns the background color of the ad.

#### public int getBackgroundGradientBottom ()

Returns the color of the background gradient at the bottom of the ad.

#### public int getBackgroundGradientTop ()

Returns the color of the background gradient at the top of the ad.

#### public int getBorderColor ()

Returns the border color of the ad container.

#### public int getBorderThickness ()

Returns the thickness of the border in pixels around the ad container.

#### public int getBorderType ()

Returns the type of border around the ad container.

#### public int getCallButtonColor ()

Returns the color of the call button when a call extension is shown.

#### public String getCustomChannels ()

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

#### 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 int getDescriptionTextColor ()

Returns the color of the ad description.

#### public String getFontFace ()

Returns the font used to render the ad. The same font is used in the header, the description and the anchor.

#### public int getHeaderTextColor ()

Returns the font size of the header text in pixels.

#### public int getHeaderTextSize ()

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

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

#### 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 getQuery ()

Returns the query of the search ad request.

#### public boolean isTestDevice (Context context)

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