|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.ads.AdRequest
public class AdRequest
An AdRequest
object contains information about the ad to fetch. The
information is primarily for targeting, though parameters can also be set to
control ad formats and such.
Nested Class Summary | |
---|---|
static class |
AdRequest.ErrorCode
An enumeration of the various types of errors that might occur while fetching an ad. |
static class |
AdRequest.Gender
The gender of the user for targeting purposes. |
Field Summary | |
---|---|
static String |
LOGTAG
The tag the SDK uses for all logging messages. |
static String |
TEST_EMULATOR
The constant for the emulator's device ID. |
static String |
VERSION
The current version of the SDK. |
Constructor Summary | |
---|---|
AdRequest()
|
Method Summary | |
---|---|
void |
addExtra(String key,
Object value)
Adds an extra ad request parameter. |
void |
addKeyword(String keyword)
Adds a keyword. |
void |
addTestDevice(String testDevice)
Causes test ads to be returned to a device. |
Map<String,Object> |
getRequestMap(Context context)
Creates a map from all of the information contained within this AdRequest . |
boolean |
isTestDevice(Context context)
Returns true if this device will have test ads returned or
false if real ads are returned. |
void |
setBirthday(String birthday)
Sets the user's birthday for targeting purposes. |
void |
setExtras(Map<String,Object> extras)
Sets the extra ad request parameters. |
void |
setGender(AdRequest.Gender gender)
Sets the user's gender for targeting purposes. |
void |
setKeywords(Set<String> keywords)
Sets the keywords. |
void |
setLocation(Location location)
Sets the user's location for targeting purposes. |
void |
setPlusOneOptOut(boolean plusOneOptOut)
Sets the publisher +1 opt out bit. |
void |
setTestDevices(Set<String> testDevices)
Sets the test devices. |
void |
setTesting(boolean testing)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String VERSION
public static final String LOGTAG
public static final String TEST_EMULATOR
Constructor Detail |
---|
public AdRequest()
Method Detail |
---|
public void setGender(AdRequest.Gender gender)
gender
- the gender.public void setBirthday(String birthday)
birthday
- the birthday String
in the format of
YYYYMMDD
.public void setPlusOneOptOut(boolean plusOneOptOut)
plusoneOptOut
- true
if the publisher desires to opt out of
showing the +1 widget on ads in their application.public void setKeywords(Set<String> keywords)
keywords
- the keywords.addKeyword(String)
public void addKeyword(String keyword)
keyword
- the keyword to add.setKeywords(Set)
public void setExtras(Map<String,Object> extras)
extras
- the new map of values to send with the ad request.addExtra(String, Object)
public void addExtra(String key, Object value)
key
- the key of the extra to add.value
- the value of the extra to add.setExtras(Map)
public void setLocation(Location location)
location
- the Location
.@Deprecated public void setTesting(boolean testing)
addTestDevice(String)
or
setTestDevices(Set)
instead.
testing
- true
if the test ads should be shown on emulators.addTestDevice(String)
,
setTestDevices(Set)
public Map<String,Object> getRequestMap(Context context)
AdRequest
.
Map
with all the parameters and their associated keys.public void addTestDevice(String testDevice)
logcat
while
requesting an ad to see how to return test ads to a device. There will
be a log message with the code needed to add the current device to the
list of test devices. For example:
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); adRequest.addTestDevice("E83D20734F72FB3108F104ABC0FFC738"); // My T-Mobile G1 test phone
testDevice
- the device ID. Use TEST_EMULATOR
to get test
ads in the emulator.setTestDevices(Set)
public void setTestDevices(Set<String> testDevices)
testDevices
- the test devices.addTestDevice(String)
public boolean isTestDevice(Context context)
true
if this device will have test ads returned or
false
if real ads are returned.
context
- the Context
used to determine the current device's
ID.
true
if the current device has been enabled for testing.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |