Skip to main content

Rewarded Ads

Users can choose to interact with these ads in exchange for in-app rewards, such as extra points or lives in a game.

Introduction

Rewarded ads are usually displayed on the game page of the App. You will get corresponding rewards after playing the ad in full screen (Supports Horizontal Screen). The ad content supports pictures and videos. The effect is as shown in the figure:

Full screen image

Load Ads

Please set the corresponding parameters and listening callbacks.

// Initialize the rewarded ad object, where "rewarded_id" is the rewarded ad slot ID
TRewarded tRewarded = new TRewarded("rewarded_id");
// Set up the ad listener
tRewarded.setAdListener(new TAdListener());
//Load ads
tRewarded.loadAd();

// Ad listener, listens for ad request timeout, loading completion (filling), display, click, exception, close, and incentive action callbacks
private static class TAdListener extends AdListener {

// Abnormal callback (applicable ad slots: all ad slots)
@Override
public void onError(TaErrorCode adError) {
Log.d(TAG,"Ad failed callback");
}

// Loading completion callback (applicable ad slots: Splash、Interstitial、Banner、Reward)
@Override
public void onAdLoaded() {
Log.d(TAG,"Ad loaded callback");
}

// Click callback (applicable ad slots: Splash、Interstitial、Banner、Reward)
@Override
public void onAdClicked() {
Log.d(TAG,"Ad click callback");
}

// Display callback (applicable ad slots: Splash、Interstitial、Banner、Reward)
@Override
public void onAdShow() {
Log.d(TAG,"Ad show callback");
}

// Request timeout callback (applicable ad slots: all ad slots)
@Override
public void onTimeOut() {
Log.d(TAG,"Ad request timeout callback");
}

// Close callback (applicable ad slots: Splash、Interstitial、Reward)
@Override
public void onAdClosed() {
Log.d(TAG,"Ad close callback");
}

// Incentive callback (applicable ad slots: Reward)
@Override
public void onRewarded() {
Log.d(TAG,"Ad rewarded callback");
}
}

Display Ads

Please show rewarded ads.

// If the current ad is loaded successfully and is within the delivery period, it will be displayed; otherwise, it will not be displayed
if (tRewarded != null && tRewarded.isReady()) {
tRewarded.show();
}

Destroy Ads

After exiting the advertising scene, please destroy the advertising object.

@Override
protected void onDestroy() {
super.onDestroy();
if (tRewarded != null) {
tRewarded.destroy();
tRewarded = null;
}
}

Other APIs

API callIntroduce
tRewarded.isAdValid()Whether the current ad is within the validity period
tRewarded.isLoaded()Whether the current ad is loaded successfully
tRewarded.isReady()If the current ad is loaded successfully and is within the delivery period, it will be displayed; otherwise, it will not be displayed.