目录

NativeAd

Class Info

public abstract class NativeAd extends Object

Native ad.

Nested Class Summary

Qualifier and Type

Class Name and Description

static interface

NativeAd.NativeAdLoadedListener

Listens for native ad loading successes.

Public Constructor Summary

Constructor Name

NativeAd()

Constructs a native ad.

Public Method Summary

Qualifier and Type

Method Name and Description

abstract void

destroy()

Destroys an ad object.

abstract void

dislikeAd(DislikeAdReason reason)

Dislikes the current ad as requested by a user.

abstract String

getAdSign()

Obtains a flag indicating whether a task is an ad task.

abstract String

getAdSource()

Obtains the ad source.

abstract String

getCallToAction()

Obtains the text to be displayed on an ad interaction button, for example, View details or Install.

abstract int

getCreativeType()

Obtains an ad creative type.

abstract String

getDescription()

Obtains the description of an ad.

abstract List<DislikeAdReason>

getDislikeAdReasons()

Obtains the "Dislike this ad" option.

Map<String, String>

getExt()

Obtains ad extension information.

abstract Image

getIcon()

Obtains the icon of an ad.

abstract List<Image>

getImages()

Obtains multi-image assets of an ad.

abstract MediaContent

getMediaContent()

Obtains the multimedia content for an ad.

abstract String

getTitle()

Obtains the title of an ad.

abstract String

getUniqueId()

Obtains the advertising ID.

abstract Video

getVideo()

Obtains video assets of an ad.

abstract VideoOperator

getVideoOperator()

Obtains the video controller of an ad.

abstract String

getWhyThisAd()

Obtains the redirection link to Why this ad.

abstract void

gotoWhyThisAdPage(Context context)

Goes to the Why this ad page.

abstract boolean

isCustomClickAllowed()

Checks whether custom click gestures are enabled.

abstract boolean

isCustomDislikeThisAdEnabled()

Checks whether custom ad disliking is enabled.

abstract void

onAdClose(Context context, List<String> keyWords)

Called when an ad is closed.

abstract void

recordClickEvent()

Reports a custom click event.

abstract boolean

recordClickEvent(Bundle data)

Reports a custom click event.

abstract boolean

recordImpressionEvent(Bundle data)

Reports an ad impression.

abstract boolean

recordShowStartEvent(Bundle data)

Reports an event indicating that an ad starts to be shown.

abstract void

setAllowCustomClick()

Enables custom click gestures.

abstract void

setDislikeAdListener(DislikeAdListener listener)

Sets an ad disliking listener.

abstract void

triggerClick(Bundle data)

Reports a click.

abstract boolean

hasAdvertiserInfo()

Checks whether advertiser information is delivered for the current ad.

abstract List<AdvertiserInfo>

getAdvertiserInfo()

Obtains the advertiser information.

abstract void

showAppDetailPage(Context context)

Shows the introduction page of the promoted app.

abstract boolean

isTransparencyOpen()

Checks whether ad transparency information is displayed.

abstract String

getTransparencyTplUrl()

Obtains the redirection URL of the ad transparency information.

abstract int

getInterActionType()

Obtains the ad purpose.

abstract void

setVideoConfiguration(VideoConfiguration videoConfiguration)

Sets video playback parameters.

For details, please refer to VideoConfiguration.

abstract BiddingInfo

getBiddingInfo()

Obtains the real-time bidding data returned to the app.

void

sendBiddingSuccess(Map<String, Object> sendSuccessInfo, ReportUrlListener reportUrlListener)

Reports the bidding success result.

void

sendBiddingFailed(Map<String, Object> sendFailInfo, ReportUrlListener reportUrlListener)

Reports the bidding failure result.

Public Constructors

[h2]NativeAd

Constructor

public NativeAd()

Constructs a native ad.

Public Methods

[h2]destroy

Method

public abstract void destroy()

Destroys an ad object. After calling destroy(), do not call any other methods on the ad object.

[h2]dislikeAd

Method

public abstract void dislikeAd(DislikeAdReason reason)

Dislikes the current ad as requested by a user.

Parameters

Name

Description

reason

Reason why a user dislikes an ad.

[h2]getAdSign

Method

public abstract String getAdSign()

Obtains a flag indicating whether a task is an ad task.

Returns

Type

Description

String

Whether a task is an ad task.

  • 0: no
  • 1: yes

The default value is 1.

[h2]getAdSource

Method

public abstract String getAdSource()

Obtains the ad source.

Returns

Type

Description

String

Ad source.

[h2]getCallToAction

Method

public abstract String getCallToAction()

Obtains the text to be displayed on an ad interaction button, for example, View details or Install.

Returns

Type

Description

String

Text to be displayed on a button.

[h2]getCreativeType

Method

public abstract int getCreativeType()

Obtains an ad creative type.

Returns

Type

Description

int

Ad creative type.

  • 1: text.
  • 2: large image.
  • 3: large image with text.
  • 4: GIF image
  • 5: no specific type (for the scenario where metadata is returned in magazine unlock).
  • 6: video with text.
  • 7: small image with text.
  • 8: three small images with text.
  • 9: video.
  • 12: dual-slot video.
  • 100: unknown type, which is returned when an error occurs.
  • 101: text with a download button.
  • 102: large image with a download button.
  • 103: large image with text and a download button.
  • 106: video with text and a download button.
  • 107: small image with text and a download button.
  • 108: three small images with text and a download button.

[h2]getDescription

Method

public abstract String getDescription()

Obtains the description of an ad.

Returns

Type

Description

String

Ad description.

[h2]getDislikeAdReasons

Method

public abstract List<DislikeAdReason> getDislikeAdReasons()

Obtains the "Dislike this ad" option.

Returns

Type

Description

List<DislikeAdReason>

"Dislike this ad" option.

[h2]getExt

Method

public Map<String, String> getExt()

Obtains ad extension information.

Returns

Type

Description

Map<String, String>

Ad extension information.

[h2]getIcon

Method

public abstract Image getIcon()

Obtains the icon of an ad.

Returns

Type

Description

Image

Icon of an ad.

[h2]getImages

Method

public abstract List<Image> getImages()

Obtains multi-image assets of an ad.

Returns

Type

Description

List<Image>

Multi-image assets of an ad.

[h2]getMediaContent

Method

public abstract MediaContent getMediaContent()

Obtains the multimedia content for an ad.

Returns

Type

Description

MediaContent

Multimedia content for an ad.

[h2]getTitle

Method

public abstract String getTitle()

Obtains the title of an ad.

Returns

Type

Description

String

Ad title.

[h2]getUniqueId

Method

public abstract String getUniqueId()

Obtains the advertising ID.

Returns

Type

Description

String

Advertising ID.

[h2]getVideo

Method

public abstract Video getVideo()

Obtains video assets of an ad.

Returns

Type

Description

Video

Video assets of an ad.

[h2]getVideoOperator

Method

public abstract VideoOperator getVideoOperator()

Obtains the video controller of an ad.

Returns

Type

Description

VideoOperator

Video controller of an ad.

[h2]getWhyThisAd

Method

public abstract String getWhyThisAd()

Obtains the redirection link to Why this ad.

Returns

Type

Description

String

Redirection link to Why this ad.

[h2]gotoWhyThisAdPage

Method

public abstract void gotoWhyThisAdPage(Context context)

Opens the page indicating why this ad or the ad transparency information is displayed.

Parameters

Name

Description

context

Context.

[h2]isCustomClickAllowed

Method

public abstract boolean isCustomClickAllowed()

Checks whether custom click gestures are enabled.

Returns

Type

Description

boolean

Whether custom click gestures are enabled.

  • true: yes
  • false: no

The default value is false.

[h2]isCustomDislikeThisAdEnabled

Method

public abstract boolean isCustomDislikeThisAdEnabled()

Checks whether custom ad disliking is enabled.

Returns

Type

Description

boolean

Whether custom ad disliking is enabled.

  • true: yes
  • false: no

The default value is false.

[h2]onAdClose

Method

public abstract void onAdClose(Context context, List<String> keyWords)

Called when an ad is closed.

Parameters

Name

Description

context

Context.

keyWords

Ad keyword.

[h2]recordClickEvent

Method

public abstract void recordClickEvent()

Reports a custom click event.

[h2]recordClickEvent(Bundle data)

Method

public abstract boolean recordClickEvent(Bundle data)

Reports a custom click event.

Parameters

Name

Description

data

Click event data. You can pass clickX, clickY, and creativeSize to data, which helps traffic monetization.

  • clickX: horizontal coordinate of the click position relative to the ad unit.

    Value type: int; value unit: px; example: 10

  • clickY: vertical coordinate of the click position relative to the ad unit.

    Value type: int; value unit: px; example: 10

  • creativeSize: ad unit dimensions (width x height).

    Value type: string; value unit: px; example: 1080 x 600

Returns

Type

Description

boolean

Whether a custom click event is reported successfully.

  • true: yes
  • false: no

The default value is false.

[h2]recordImpressionEvent

Method

public abstract boolean recordImpressionEvent(Bundle data)

Reports an ad impression.

Parameters

Name

Description

data

Impression data.

Returns

Type

Description

boolean

Whether an ad impression is reported successfully.

  • true: yes
  • false: no

[h2]recordShowStartEvent

Method

public abstract boolean recordShowStartEvent(Bundle data)

Reports an event indicating that an ad starts to be shown.

Parameters

Name

Description

data

Data carried in the reported event.

Returns

Type

Description

boolean

Whether an event indicating that an ad starts to be shown is reported successfully.

  • true: yes
  • false: no

[h2]setAllowCustomClick

Method

public abstract void setAllowCustomClick()

Enables custom click gestures.

[h2]setDislikeAdListener

Method

public abstract void setDislikeAdListener(DislikeAdListener listener)

Sets an ad disliking listener.

Parameters

Name

Description

listener

Ad disliking listener.

[h2]triggerClick

Method

public abstract void triggerClick(Bundle data)

Manually triggers a click.

Parameters

Name

Description

data

Click data. You can pass clickX, clickY, and creativeSize to data, which helps traffic monetization.

  • clickX: horizontal coordinate of the click position relative to the ad unit.

    Value type: int; value unit: px; example: 10

  • clickY: vertical coordinate of the click position relative to the ad unit.

    Value type: int; value unit: px; example: 10

  • creativeSize: ad unit dimensions (width x height).

    Value type: string; value unit: px; example: 1080 x 600

[h2]hasAdvertiserInfo

Method

public abstract boolean hasAdvertiserInfo()

Checks whether advertiser information is delivered for the current ad.

Returns

Type

Description

boolean

Whether to deliver advertiser information. The options are true (yes) and false (no).

[h2]getAdvertiserInfo

Method

public abstract List getAdvertiserInfo()

Obtains the advertiser information.

Returns

Type

Description

List<AdvertiserInfo>

Advertiser information list.

[h2]showAppDetailPage

Method

public abstract void showAppDetailPage(Context context)

Shows the introduction page of the promoted app.

Parameters

Name

Description

context

Context.

[h2]isTransparencyOpen

Method

public abstract boolean isTransparencyOpen()

Checks whether ad transparency information is displayed.

Parameters

Name

Description

boolean

Indicates whether ad transparency information is displayed.

[h2]getTransparencyTplUrl

Method

public abstract String getTransparencyTplUrl()

Obtains the redirection URL of the ad transparency information.

Parameters

Name

Description

String

Redirection URL of the ad transparency information.

[h2]getInterActionType

Method

public abstract int getInterActionType()

Obtains the ad purpose.

Returns

Type

Description

int

Ad purpose. The options are as follows:

0: for display only (No action is taken after the ad is tapped.)

1: web promotion (A web page is opened when the ad is tapped.)

2: app download (An app is downloaded when the ad is tapped.)

3: app or quick app engagement (The app or quick app is opened when the ad is tapped.)

5: app promotion (When the ad is tapped, the app is downloaded if it is not installed and opened if it is installed.)

7: e-commerce web page (When the ad is tapped, the app is downloaded if it is installed and a web page is opened if the app is not installed.)

8: scheduled download

9: HarmonyOS service

10: mini program startup

[h2]setVideoConfiguration(VideoConfiguration videoConfiguration)

Method

Public abstract void setVideoConfiguration(VideoConfiguration videoConfiguration)

Sets video playback parameters.

Returns

Type

Description

videoConfiguration

Video configuration that controls video playback.

[h2]getBiddingInfo

Method

public abstract BiddingInfo getBiddingInfo()

Obtains the real-time bidding data returned to the app.

Returns

Type

Description

BiddingInfo

Real-time bidding information returned by the ADX.

[h2]sendBiddingSuccess

Method

public void sendBiddingSuccess(Map<String, Object> sendSuccessInfo, ReportUrlListener reportUrlListener)

Reports the bidding success result.

Parameters

Name

Description

sendSuccessInfo

Macro replacement parameters when a bid is successful; of the Map type.

The key represents the macro that needs to be replaced in the URL and is of the String type, while the value represents the corresponding replacement information and is of the Object type.

For details about macro replacement, please refer to Real-Time Bidding.

ReportUrlListener

Called when the bidding result is reported.

[h2]sendBiddingFailed

Method

public void sendBiddingFailed(Map<String, Object> sendFailInfo, ReportUrlListener reportUrlListener)

Reports the bidding failure result.

Parameters

Name

Description

sendFailInfo

Macro replacement parameters for a failed bid; of the Map type.

The key represents the macro that needs to be replaced in the URL and is of the String type, while the value represents the corresponding replacement information and is of the Object type.

For details about macro replacement, please refer to Real-Time Bidding.

ReportUrlListener

Called when the bidding result is reported.