目录

AdParam.Builder

Class Info

public static final class AdParam.Builder extends Object

Ad request builder.

Public Constructor Summary

Constructor Name

Builder()

Constructs an ad request builder.

Public Method Summary

Qualifier and Type

Method Name and Description

AdParam

build()

Constructs an AdParam object.

AdParam.Builder

setAdContentClassification(String adContentClassification)

Sets the maximum ad content rating.

AdParam.Builder

setAppCountry(String appCountry)

Sets the country/region code corresponding to the language in which an ad needs to be returned for an app.

AdParam.Builder

setAppLang(String appLang)

Sets the language in which an ad needs to be returned for an app.

AdParam.Builder

setBelongCountryCode(String countryCode)

Sets the code of the country/region to which an app belongs.

AdParam.Builder

setContentBundle(String contentBundle)

Sets content bundle.

AdParam.Builder

setConsent(String consent)

Sets the user consent string that complies with TCF v2.0.

AdParam.Builder

setDetailedCreativeTypeList(List<Integer> detailedCreativeTypeList)

Sets the requested creative type of a native ad.

AdParam.Builder

setGender(int gender)

Sets the gender.

AdParam.Builder

setLocation(Location location)

Sets the location information passed by your app.

AdParam.Builder

setNonPersonalizedAd(Integer nonPersonalizedAd)

Sets whether to request personalized ads.

AdParam.Builder

setRequestLocation(boolean requestLocation)

Sets whether to carry location information in an ad request. By default, the information is carried.

AdParam.Builder

setTagForChildProtection(Integer tagForChildProtection)

Sets whether to process ad requests according to the COPPA.

AdParam.Builder

setTagForUnderAgeOfPromise(Integer tagForUnderAgeOfPromise)

Sets whether to process ad requests as directed to users under the age of consent.

AdParam.Builder

setIsQueryUseEnabled(Integer isQueryUseEnabled)

Sets whether search keywords can be used.

AdParam.Builder

setTMax(Integer tMax)

Sets the maximum transaction timeout interval (including the network delay), in milliseconds.

AdParam.Builder

setCur(List<String> curs)

Sets the list of currencies for the transaction request.

AdParam.Builder

addBiddingParamMap(String slotId, BiddingParam biddingParam)

Sets the parameters for a real-time bidding ad unit.

AdParam.Builder

setBiddingParamMap(Map<String, BiddingParam> biddingParamMap)

Sets the parameters for a real-time bidding ad unit.

AdParam.Builder

setSupportTemplate (Boolean support)

Sets to support template ads.

Public Constructors

[h2]Builder

Constructor

public Builder()

Constructs an ad request builder.

Public Methods

[h2]build

Method

public final AdParam build()

Constructs an AdParam object. If an error occurs, null is returned.

Returns

Type

Description

AdParam

AdParam object. If an error occurs, null is returned.

[h2]setAdContentClassification

Method

public final AdParam.Builder setAdContentClassification(String adContentClassification)

Sets the maximum ad content rating.

Parameters

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setAppCountry

Method

public final AdParam.Builder setAppCountry(String appCountry)

Sets the country/region code corresponding to the language in which an ad needs to be returned for an app.

Parameters

Name

Description

appCountry

Country/Region code corresponding to the language in which an ad needs to be returned for an app.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setAppLang

Method

public final AdParam.Builder setAppLang(String appLang)

Sets the language in which an ad needs to be returned for an app.

Parameters

Name

Description

appLang

Language in which an ad needs to be returned for an app.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setBelongCountryCode

Method

public final AdParam.Builder setBelongCountryCode(String countryCode)

Sets the code of the country/region to which an app belongs.

Parameters

Name

Description

countryCode

Code of the country/region to which an app belongs.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setContentBundle

Method

public final AdParam.Builder setContentBundle(String contentBundle)

Sets content bundle.

Parameters

Name

Description

contentBundle

Content bundle. The parameter value is a key-value pair, and the type of each element is as follows:

  • Key: JSON string.
  • Value: JSON string array. Either one or more values are allowed.

Key

Description and Value

channelCategoryCode

Channel name. Example: TV series

title

Title of the playing video. Example: Game of Thrones

tags

Content tag of the playing video. Example: fantasy

relatedPeople

Cast members of the playing video, such as directors and stars. Example: David Benioff

content

Introduction of the playing video. Example: Nine noble families fight for control over the lands of Westeros.

contentID

ID of the playing video assigned by the media app. Example: 132123

category

Level-1 category. Example: classics

subcategory

Level-2 category. Example: historical drama

NOTE:

This parameter can be left empty when being passed to the server.

thirdCategory

Level-3 category. Example: mystery

Sample code:

{"channelCategoryCode":["TV series"],"title":["Game of Thrones"],"tags":["fantasy"],"relatedPeople":["David Benioff"],"content":["Nine noble families fight for control over the lands of Westeros."],"contentID":["123123"],"category":["classics"],"subcategory":["historical drama"],"thirdCategory":["mystery"]}

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setConsent

Method

public final AdParam.Builder setConsent(String consent)

Sets the user consent string that complies with TCF v2.0.

Parameters

Name

Description

consent

User consent string, which complies with Consent String Format in TCF v2.0.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setDetailedCreativeTypeList

Method

public final AdParam.Builder setDetailedCreativeTypeList(List<Integer> detailedCreativeTypeList)

Sets the requested creative type of a native ad.

Parameters

Name

Description

detailedCreativeTypeList

Creative types of a requested native ad. For details about supported creative types, please refer to DetailedCreativeType.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setGender

Method

public final AdParam.Builder setGender(int gender)

Sets the gender.

Parameters

Name

Description

gender

Gender. For details, please refer to com.huawei.hms.ads.Gender.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setLocation

Method

public final AdParam.Builder setLocation(Location location)

Sets the location information passed by your app.

Parameters

Name

Description

location

Location information passed by your app.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setNonPersonalizedAd

Method

public final AdParam.Builder setNonPersonalizedAd(Integer nonPersonalizedAd)

Sets whether to request personalized ads.

Parameters

Name

Description

nonPersonalizedAd

The options are as follows:

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setRequestLocation

Method

public final AdParam.Builder setRequestLocation(boolean requestLocation)

Sets whether to carry location information in an ad request. By default, the information is carried.

Parameters

Name

Description

requestLocation

Whether location information is carried in an ad request.

  • true: yes
  • false: no

The default value is true.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setTagForChildProtection

Method

public final AdParam.Builder setTagForChildProtection(Integer tagForChildProtection)

Sets whether to process ad requests according to the COPPA.

Parameters

Name

Description

tagForChildProtection

Indicates whether to process ad requests according to the COPPA.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setTagForUnderAgeOfPromise

Method

public final AdParam.Builder setTagForUnderAgeOfPromise(Integer tagForUnderAgeOfPromise)

Sets whether to process ad requests as directed to users under the age of consent.

Parameters

Name

Description

tagForUnderAgeOfPromise

Indicates whether to process ad requests as directed to users under the age of consent.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setIsQueryUseEnabled

Method

public final AdParam.Builder setIsQueryUseEnabled(Integer isQueryUseEnabled)

Sets whether search keywords can be used.

Parameters

Name

Description

IsQueryUseEnabled

Indicates whether search keywords can be used. The options are as follows:

  • IsQueryUseEnabled.QUERY_USE_ENABLED
  • IsQueryUseEnabled.QUERY_USE_DISABLED

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setTMax

Method

public AdParam.Builder setTMax (Integer tMax)

Sets the maximum transaction timeout interval (including the network delay), in milliseconds.

Parameters

Name

Description

tMax

Maximum transaction timeout interval (including the network delay), in milliseconds.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setCur

Method

public AdParam.Builder setCur(List<String> curs)

Sets the currency of the bid for a real-time bidding ad unit.

Parameters

Name

Description

curs

Currency supported by the bidding request. The value is of the List<String> type. Currently, the following options are supported: CNY, USD, EUR, GBP, and JPY. If this parameter is left empty, the default value CNY will be used.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]addBiddingParamMap

Method

public AdParam.Builder addBiddingParamMap(String slotId, BiddingParam biddingParam)

Sets the parameters for a real-time bidding ad unit.

Parameters

Name

Description

slotId

Ad unit ID. The real-time bidding parameters are set on a per ad unit basis.

biddingParam

BiddingParam object.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setBiddingParamMap

Method

public AdParam.Builder setBiddingParamMap(Map<String, BiddingParam > biddingParamMap)

Sets the parameters for a real-time bidding ad unit.

Parameters

Name

Description

biddingParamMap

This parameter is of the Map type and set on a per ad unit basis. In the Map<String, BiddingParam> structure, the key represents an ad unit ID, and the value is a BiddingParam object.

Returns

Type

Description

AdParam.Builder

AdParam builder.

[h2]setSupportTemplate

Method

public AdParam.Builder setSupportTemplate (Boolean support)

Sets to support template ads.

Parameters

Name

Description

support

The parameter is of the Boolean type. true: Template ads are supported. false: Template ads are not supported.

Returns

Type

Description

AdParam.Builder

AdParam builder.