- If the Ad Placement is set to Auto Load, you do not need to call the
ATRewardVideoAd#load()method to load the ad- We recommend initializing the auto-load Rewarded Video ad on the main page
- The context of
ATRewardVideoAutoAd#init()must be an Activity, to avoid loading failures on some platforms
- If the Ad Placement is set to Auto Load, you do not need to call the
TURewardVideoAd#load()method to load the ad- We recommend initializing the auto-load Rewarded Video ad on the main page
- The context of
TURewardVideoAutoAd#init()must be an Activity, to avoid loading failures on some platforms
- Before displaying, check whether
isAdReady()is ready. Once ready, callshow()to display the ad; if not ready, start loading the ad and wait for the load to succeed;- Before displaying, first check whether the app is in the foreground. Calling
show()while in the background may cause the ad to be displayed outside the app or fail to display properly;- The auto-load Rewarded Video implements the auto-load logic internally, so avoid displaying the ad directly in the
onRewardVideoAutoLoadedcallback
- Auto-load Rewarded Video supports the server-side callback (S2S) reward delivery mechanism, and also supports the server-side callback feature of each ad platform. Please refer to Rewarded Video Server-Side Reward (S2S) Guide
//--------------------- Method 1 -------------------------
//Pass in the Ad Placement id directly during initialization; one or more ids are supported.
String[] placementIdArr = new String[]{"your placementId_1 ", "your placementId_2"};
//If you need to set the server-side callback localExtra info, make sure to do it before ATRewardVideoAutoAd.init()
setPlacementIdLocalExtra(placementIdArr);
ATRewardVideoAutoAd.init(activity, placementIdArr, new ATRewardVideoAutoLoadListener() {
@Override
public void onRewardVideoAutoLoaded(String placementId) {}
@Override
public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {}
});
//--------------------- Method 1 -------------------------
//--------------------- Method 2 -------------------------
//Initialize first, then pass in the Ad Placement id; one or more ids are supported
String[] placementIdArr = new String[]{"your placementId_1 ", "your placementId_2"};
//If you need to set the server-side callback localExtra info, make sure to do it before ATRewardVideoAutoAd.init()
setPlacementIdLocalExtra(placementIdArr);
ATRewardVideoAutoAd.init(activity, null, new ATRewardVideoAutoLoadListener() {
@Override
public void onRewardVideoAutoLoaded(String placementId) {}
@Override
public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {}
});
//addPlacementId() must be called after ATRewardVideoAutoAd.init()
ATRewardVideoAutoAd.addPlacementId(placementIdArr);
//--------------------- Method 2 -------------------------
//Set the server-side callback localExtra info
private void setPlacementIdLocalExtra(String... placementIdArr) {
for (String placementId : placementIdArr) {
String userid = "test_userid_001";
String userdata = "test_userdata_001";
Map localMap = new HashMap<>();
localMap.put(ATAdConst.KEY.USER_ID, userid);
localMap.put(ATAdConst.KEY.USER_CUSTOM_DATA, userdata);
//Takes effect from the next ad load
ATRewardVideoAutoAd.setLocalExtra(placementId, localMap);
}
}
//--------------------- Method 1 -------------------------
//Pass in the Ad Placement id directly during initialization; one or more ids are supported.
String[] placementIdArr = new String[]{"your placementId_1 ", "your placementId_2"};
//If you need to set the server-side callback localExtra info, make sure to do it before TURewardVideoAutoAd.init()
setPlacementIdLocalExtra(placementIdArr);
TURewardVideoAutoAd.init(activity, placementIdArr, new TURewardVideoAutoLoadListener() {
@Override
public void onRewardVideoAutoLoaded(String placementId) {}
@Override
public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {}
});
//--------------------- Method 1 -------------------------
//--------------------- Method 2 -------------------------
//Initialize first, then pass in the Ad Placement id; one or more ids are supported
String[] placementIdArr = new String[]{"your placementId_1 ", "your placementId_2"};
//If you need to set the server-side callback localExtra info, make sure to do it before TURewardVideoAutoAd.init()
setPlacementIdLocalExtra(placementIdArr);
TURewardVideoAutoAd.init(activity, null, new TURewardVideoAutoLoadListener() {
@Override
public void onRewardVideoAutoLoaded(String placementId) {}
@Override
public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {}
});
//addPlacementId() must be called after TURewardVideoAutoAd.init()
TURewardVideoAutoAd.addPlacementId(placementIdArr);
//--------------------- Method 2 -------------------------
//Set the server-side callback localExtra info
private void setPlacementIdLocalExtra(String... placementIdArr) {
for (String placementId : placementIdArr) {
String userid = "test_userid_001";
String userdata = "test_userdata_001";
Map localMap = new HashMap<>();
localMap.put(TUAdConst.KEY.USER_ID, userid);
localMap.put(TUAdConst.KEY.USER_CUSTOM_DATA, userdata);
//Takes effect from the next ad load
TURewardVideoAutoAd.setLocalExtra(placementId, localMap);
}
}
Note:
- If the Ad Placement IDs are the same, both
init()andaddPlacementId()only need to be called once.
ATRewardVideoAutoAd.show(activity, "your placement id", new ATRewardVideoAutoEventListener() {
@Override
public void onRewardedVideoAdPlayStart(ATAdInfo adInfo) {}
@Override
public void onRewardedVideoAdPlayEnd(ATAdInfo adInfo) {}
@Override
public void onRewardedVideoAdPlayFailed(AdError adError, ATAdInfo adInfo) {}
@Override
public void onRewardedVideoAdClosed(ATAdInfo adInfo) {}
@Override
public void onRewardedVideoAdPlayClicked(ATAdInfo adInfo) {}
@Override
public void onReward(ATAdInfo adInfo) {}
});
TURewardVideoAutoAd.show(activity, "your placement id", new TURewardVideoAutoEventListener() {
@Override
public void onRewardedVideoAdPlayStart(TUAdInfo adInfo) {}
@Override
public void onRewardedVideoAdPlayEnd(TUAdInfo adInfo) {}
@Override
public void onRewardedVideoAdPlayFailed(AdError adError, TUAdInfo adInfo) {}
@Override
public void onRewardedVideoAdClosed(TUAdInfo adInfo) {}
@Override
public void onRewardedVideoAdPlayClicked(TUAdInfo adInfo) {}
@Override
public void onReward(TUAdInfo adInfo) {}
});
● ATRewardVideoAutoAd
Operation class for loading and displaying auto-load Rewarded Video ads
| Method | Description |
|---|---|
| void init(Context context, String[] placementIds, ATRewardVideoAutoLoadListener loadListener) | Initialization method for the auto-load Rewarded Video ad; after initialization, it automatically starts loading ads for the specified Ad Placements context: an activity is recommended placementIds: Ad Placement IDs to enable Auto Load (you may pass null first and later call addPlacementId() to pass the Ad Placement IDs) loadListener: ad fill callback |
| void addPlacementId(String... placementIds) | Set multiple auto-load Rewarded Video Ad Placement ids for auto loading placementIds: Ad Placement IDs to be auto-loaded |
| void removePlacementId(String... placementIds) | Cancel auto loading for multiple auto-load Rewarded Video Ad Placement ids placementIds: Ad Placement IDs that no longer need to be auto-loaded |
| void setLocalExtra(String placementId, Map<String, Object> localExtra) | Set local parameters for the specified Ad Placement placementId: Ad Placement ID localExtra: local parameters, whose keys are obtained via AdConst.KEY |
| boolean isAdReady(String placementId) | Determine whether the Ad Placement has an ad available to display placementId: Ad Placement ID to query |
| void show(Activity activity, String placementId, ATRewardVideoAutoEventListener eventListener) | Display the Rewarded Video ad of this Ad Placement activity: the Activity that displays the ad placementId: Ad Placement ID to display eventListener: Rewarded Video ad display and reward callback |
| void show(Activity activity, String placementId, ATShowConfig showConfig, ATRewardVideoAutoEventListener eventListener) | Display the Rewarded Video ad of this Ad Placement activity: the Activity that displays the ad placementId: Ad Placement ID to display showConfig: ad display configuration, including custom parameters and the Ad Scenario eventListener: Rewarded Video ad display and reward callback |
● ATRewardVideoAutoLoadListener
Callback listener for auto-load Rewarded Video ad loading events
| Method | Description |
|---|---|
| void onRewardVideoAutoLoaded(String placementId) | Callback for a successful ad load of the corresponding Ad Placement placementId: the corresponding Ad Placement ID |
| void onRewardVideoAutoLoadFail(String placementId, AdError errorCode) | Callback for a failed ad load of the corresponding Ad Placement placementId: Ad Placement ID errorCode: ad load failure info |
● ATRewardVideoAutoEventListener
Callback listener for auto-load Rewarded Video ad display events
| Method | Description |
|---|---|
| void onRewardedVideoAdPlayStart(ATAdInfo adInfo) | Callback when the ad starts playing (i.e. the Rewarded Video impression callback) adInfo: ad info object |
| void onRewardedVideoAdPlayEnd(ATAdInfo adInfo) | Callback when the ad finishes playing adInfo: ad info object |
| void onRewardedVideoAdPlayFailed(AdError adError, ATAdInfo adInfo) | Callback when the ad fails to play adError: ad info object adInfo: ad display failure info |
| void onReward(ATAdInfo adInfo) | This callback is triggered when the reward is delivered. We recommend that developers deliver the reward in this callback, which is generally called before onRewardedVideoAdClosed adInfo: ad info object |
| void onRewardedVideoAdClosed(ATAdInfo adInfo) | Ad close callback adInfo: ad info object |
| void onRewardedVideoAdPlayClicked(ATAdInfo adInfo) | Ad click adInfo: ad info object |
| void onDeeplinkCallback(ATAdInfo adInfo, boolean isSuccess) | deeplink callback, for Adx and OnlineApi ads adInfo: ad info object isSuccess: whether it succeeded, true = success, false = failure |
● TURewardVideoAutoAd
Operation class for loading and displaying auto-load Rewarded Video ads
| Method | Description |
|---|---|
| void init(Context context, String[] placementIds, TURewardVideoAutoLoadListener loadListener) | Initialization method for the auto-load Rewarded Video ad; after initialization, it automatically starts loading ads for the specified Ad Placements context: an activity is recommended placementIds: Ad Placement IDs to enable Auto Load (you may pass null first and later call addPlacementId() to pass the Ad Placement IDs) loadListener: ad fill callback |
| void addPlacementId(String... placementIds) | Set multiple auto-load Rewarded Video Ad Placement ids for auto loading placementIds: Ad Placement IDs to be auto-loaded |
| void removePlacementId(String... placementIds) | Cancel auto loading for multiple auto-load Rewarded Video Ad Placement ids placementIds: Ad Placement IDs that no longer need to be auto-loaded |
| void setLocalExtra(String placementId, Map<String, Object> localExtra) | Set local parameters for the specified Ad Placement placementId: Ad Placement ID localExtra: local parameters, whose keys are obtained via TUAdConst.KEY |
| boolean isAdReady(String placementId) | Determine whether the Ad Placement has an ad available to display placementId: Ad Placement ID to query |
| void show(Activity activity, String placementId, TURewardVideoAutoEventListener eventListener) | Display the Rewarded Video ad of this Ad Placement activity: the Activity that displays the ad placementId: Ad Placement ID to display eventListener: Rewarded Video ad display and reward callback |
| void show(Activity activity, String placementId, TUShowConfig showConfig, TURewardVideoAutoEventListener eventListener) | Display the Rewarded Video ad of this Ad Placement activity: the Activity that displays the ad placementId: Ad Placement ID to display showConfig: ad display configuration, including custom parameters and the Ad Scenario eventListener: Rewarded Video ad display and reward callback |
● TURewardVideoAutoLoadListener
Callback listener for auto-load Rewarded Video ad loading events
| Method | Description |
|---|---|
| void onRewardVideoAutoLoaded(String placementId) | Callback for a successful ad load of the corresponding Ad Placement placementId: the corresponding Ad Placement ID |
| void onRewardVideoAutoLoadFail(String placementId, AdError errorCode) | Callback for a failed ad load of the corresponding Ad Placement placementId: Ad Placement ID errorCode: ad load failure info |
● TURewardVideoAutoEventListener
Callback listener for auto-load Rewarded Video ad display events
| Method | Description |
|---|---|
| void onRewardedVideoAdPlayStart(TUAdInfo adInfo) | Callback when the ad starts playing (i.e. the Rewarded Video impression callback) adInfo: ad info object |
| void onRewardedVideoAdPlayEnd(TUAdInfo adInfo) | Callback when the ad finishes playing adInfo: ad info object |
| void onRewardedVideoAdPlayFailed(AdError adError, TUAdInfo adInfo) | Callback when the ad fails to play adError: ad info object adInfo: ad display failure info |
| void onReward(TUAdInfo adInfo) | This callback is triggered when the reward is delivered. We recommend that developers deliver the reward in this callback, which is generally called before onRewardedVideoAdClosed adInfo: ad info object |
| void onRewardedVideoAdClosed(TUAdInfo adInfo) | Ad close callback adInfo: ad info object |
| void onRewardedVideoAdPlayClicked(TUAdInfo adInfo) | Ad click adInfo: ad info object |
| void onDeeplinkCallback(TUAdInfo adInfo, boolean isSuccess) | deeplink callback, for Adx and OnlineApi ads adInfo: ad info object isSuccess: whether it succeeded, true = success, false = failure |
Code example: DemoRewardVideoAdActivity
- If the Ad Placement is set to Auto Load, do not call the
ATInterstitial#load()method to load the ad- We recommend initializing the auto-load Rewarded Video ad on the main page
- The context of
ATInterstitialAutoAd#init()must be an Activity, to avoid loading failures on some platforms
- If the Ad Placement is set to Auto Load, do not call the
TUInterstitial#load()method to load the ad- We recommend initializing the auto-load Rewarded Video ad on the main page
- The context of
TUInterstitialAutoAd#init()must be an Activity, to avoid loading failures on some platforms
- Before displaying, check whether
isAdReady()is ready. Once ready, callshow()to display the ad; if not ready, start loading the ad and wait for the load to succeed;- Before displaying, first check whether the app is in the foreground. Calling
show()while in the background may cause the ad to be displayed outside the app or fail to display properly;- The auto-load Interstitial implements the auto-load logic internally, so avoid displaying the ad directly in the
onInterstitialAutoLoaded()callback
//--------------------- Method 1 -------------------------
//Pass in the Ad Placement id directly during initialization; one or more ids are supported.
String[] placementIdArr = new String[]{"your placementId_1 ", "your placementId_2"};
ATInterstitialAutoAd.init(activity, placementIdArr, new ATInterstitialAutoLoadListener() {
@Override
public void onInterstitialAutoLoaded(String placementId) {}
@Override
public void onInterstitialAutoLoadFail(String placementId, AdError adError) {}
});
//--------------------- Method 1 -------------------------
//--------------------- Method 2 -------------------------
//Initialize first, then pass in the Ad Placement id; one or more ids are supported
String[] placementIdArr = new String[]{"your placementId_1 ", "your placementId_2"};
ATInterstitialAutoAd.init(activity, null, new ATInterstitialAutoLoadListener() {
@Override
public void onInterstitialAutoLoaded(String placementId) {}
@Override
public void onInterstitialAutoLoadFail(String placementId, AdError adError) {}
});
//addPlacementId() must be called after ATInterstitialAutoAd.init()
ATInterstitialAutoAd.addPlacementId(placementIdArr);
//--------------------- Method 2 -------------------------
//--------------------- Method 1 -------------------------
//Pass in the Ad Placement id directly during initialization; one or more ids are supported.
String[] placementIdArr = new String[]{"your placementId_1 ", "your placementId_2"};
TUInterstitialAutoAd.init(activity, placementIdArr, new TUInterstitialAutoLoadListener() {
@Override
public void onInterstitialAutoLoaded(String placementId) {}
@Override
public void onInterstitialAutoLoadFail(String placementId, AdError adError) {}
});
//--------------------- Method 1 -------------------------
//--------------------- Method 2 -------------------------
//Initialize first, then pass in the Ad Placement id; one or more ids are supported
String[] placementIdArr = new String[]{"your placementId_1 ", "your placementId_2"};
TUInterstitialAutoAd.init(activity, null, new TUInterstitialAutoLoadListener() {
@Override
public void onInterstitialAutoLoaded(String placementId) {}
@Override
public void onInterstitialAutoLoadFail(String placementId, AdError adError) {}
});
//addPlacementId() must be called after TUInterstitialAutoAd.init()
TUInterstitialAutoAd.addPlacementId(placementIdArr);
//--------------------- Method 2 -------------------------
Note:
- If the Ad Placement IDs are the same, both
init()andaddPlacementId()only need to be called once
ATInterstitialAutoAd.show(activity, "your placement id", new ATInterstitialAutoEventListener() {
@Override
public void onInterstitialAdShow(ATAdInfo adInfo) {}
@Override
public void onInterstitialAdVideoStart(ATAdInfo adInfo) {}
@Override
public void onInterstitialAdVideoEnd(ATAdInfo adInfo) {}
@Override
public void onInterstitialAdVideoError(AdError adError) {}
@Override
public void onInterstitialAdClose(ATAdInfo adInfo) {}
@Override
public void onInterstitialAdClicked(ATAdInfo adInfo) {}
});
TUInterstitialAutoAd.show(activity, "your placement id", new TUInterstitialAutoEventListener() {
@Override
public void onInterstitialAdShow(TUAdInfo adInfo) {}
@Override
public void onInterstitialAdVideoStart(TUAdInfo adInfo) {}
@Override
public void onInterstitialAdVideoEnd(TUAdInfo adInfo) {}
@Override
public void onInterstitialAdVideoError(AdError adError) {}
@Override
public void onInterstitialAdClose(TUAdInfo adInfo) {}
@Override
public void onInterstitialAdClicked(TUAdInfo adInfo) {}
});
● ATInterstitialAutoAd
Operation class for loading and displaying auto-load Interstitial ads
| Method | Description |
|---|---|
| void init(Context context, String[] placementIds, ATInterstitialAutoLoadListener loadListener) | Initialization method for the auto-load Interstitial ad; after initialization, it automatically starts loading ads for the specified Ad Placements context: an activity is recommended placementIds: Ad Placement IDs to enable Auto Load (you may pass null first and later call addPlacementId() to pass the Ad Placement ids) loadListener: ad fill callback |
| void addPlacementId(String... placementIds) | Set multiple auto-load Interstitial Ad Placement ids for auto loading placementIds: Ad Placement IDs to be auto-loaded |
| void removePlacementId(String... placementIds) | Cancel auto loading for multiple auto-load Interstitial Ad Placement ids placementIds: Ad Placement IDs that no longer need to be auto-loaded |
| void setLocalExtra(String placementId, Map<String, Object> localExtra) | Set custom parameters for the specified Ad Placement placementId: Ad Placement ID localExtra: custom parameters, whose keys are obtained via ATAdConst.KEY |
| boolean isAdReady(String placementId) | Determine whether the Ad Placement has an ad available to display placementId: Ad Placement ID to query |
| void show(Activity activity, String placementId, ATInterstitialAutoEventListener eventListener) | Display the Interstitial ad of this Ad Placement activity: the Activity that displays the ad placementId: Ad Placement ID to display eventListener: Interstitial ad display callback |
| void show(Activity activity, String placementId, ATShowConfig showConfig, ATInterstitialAutoEventListener eventListener) | Display the Interstitial ad of this Ad Placement activity: the Activity that displays the ad placementId: Ad Placement ID to display showConfig: ad display configuration, including custom parameters and the Ad Scenario eventListener: Interstitial ad display callback |
● ATInterstitialAutoLoadListener
Callback listener for auto-load Interstitial ad loading events
| Method | Description |
|---|---|
| void onInterstitialAutoLoaded(String placementId) | Callback for a successful ad load of the corresponding Ad Placement placementId: the corresponding Ad Placement ID |
| void onInterstitialAutoLoadFail(String placementId, AdError adError) | Callback for a failed ad load of the corresponding Ad Placement placementId: Ad Placement ID adError: ad load failure info |
● ATInterstitialAutoEventListener
Callback listener for auto-load Interstitial ad display events
| Method | Description |
|---|---|
| void onInterstitialAdShow(ATAdInfo adInfo) | Ad display callback adInfo: ad info object |
| void onInterstitialAdVideoStart(ATAdInfo adInfo) | Callback when the video ad starts playing adInfo: ad info object |
| void onInterstitialAdVideoAdPlayEnd(ATAdInfo adInfo) | Callback when the ad finishes playing adInfo: ad info object |
| void onInterstitialAdVideoError(AdError adError) | Ad display failure callback adError: ad display failure info |
| void onInterstitialAdClose(ATAdInfo adInfo) | Ad close callback adInfo: ad info object |
| void onInterstitialAdClicked(ATAdInfo adInfo) | Ad click adInfo: ad info object |
| void onDeeplinkCallback(ATAdInfo adInfo, boolean isSuccess) | deeplink callback, for Adx and Online API ads adInfo: ad info object isSuccess: whether it succeeded, true = success, false = failure |
● TUInterstitialAutoAd
Operation class for loading and displaying auto-load Interstitial ads
| Method | Description |
|---|---|
| void init(Context context, String[] placementIds, TUInterstitialAutoLoadListener loadListener) | Initialization method for the auto-load Interstitial ad; after initialization, it automatically starts loading ads for the specified Ad Placements context: an activity is recommended placementIds: Ad Placement IDs to enable Auto Load (you may pass null first and later call addPlacementId() to pass the Ad Placement ids) loadListener: ad fill callback |
| void addPlacementId(String... placementIds) | Set multiple auto-load Interstitial Ad Placement ids for auto loading placementIds: Ad Placement IDs to be auto-loaded |
| void removePlacementId(String... placementIds) | Cancel auto loading for multiple auto-load Interstitial Ad Placement ids placementIds: Ad Placement IDs that no longer need to be auto-loaded |
| void setLocalExtra(String placementId, Map<String, Object> localExtra) | Set custom parameters for the specified Ad Placement placementId: Ad Placement ID localExtra: custom parameters, whose keys are obtained via TUAdConst.KEY |
| boolean isAdReady(String placementId) | Determine whether the Ad Placement has an ad available to display placementId: Ad Placement ID to query |
| void show(Activity activity, String placementId, TUInterstitialAutoEventListener eventListener) | Display the Interstitial ad of this Ad Placement activity: the Activity that displays the ad placementId: Ad Placement ID to display eventListener: Interstitial ad display callback |
| void show(Activity activity, String placementId, TUShowConfig showConfig, TUInterstitialAutoEventListener eventListener) | Display the Interstitial ad of this Ad Placement activity: the Activity that displays the ad placementId: Ad Placement ID to display showConfig: ad display configuration, including custom parameters and the Ad Scenario eventListener: Interstitial ad display callback |
● TUInterstitialAutoLoadListener
Callback listener for auto-load Interstitial ad loading events
| Method | Description |
|---|---|
| void onInterstitialAutoLoaded(String placementId) | Callback for a successful ad load of the corresponding Ad Placement placementId: the corresponding Ad Placement ID |
| void onInterstitialAutoLoadFail(String placementId, AdError adError) | Callback for a failed ad load of the corresponding Ad Placement placementId: Ad Placement ID adError: ad load failure info |
● TUInterstitialAutoEventListener
Callback listener for auto-load Interstitial ad display events
| Method | Description |
|---|---|
| void onInterstitialAdShow(TUAdInfo adInfo) | Ad display callback adInfo: ad info object |
| void onInterstitialAdVideoStart(TUAdInfo adInfo) | Callback when the video ad starts playing adInfo: ad info object |
| void onInterstitialAdVideoAdPlayEnd(TUAdInfo adInfo) | Callback when the ad finishes playing adInfo: ad info object |
| void onInterstitialAdVideoError(AdError adError) | Ad display failure callback adError: ad display failure info |
| void onInterstitialAdClose(TUAdInfo adInfo) | Ad close callback adInfo: ad info object |
| void onInterstitialAdClicked(TUAdInfo adInfo) | Ad click adInfo: ad info object |
| void onDeeplinkCallback(TUAdInfo adInfo, boolean isSuccess) | deeplink callback, for Adx and Online API ads adInfo: ad info object isSuccess: whether it succeeded, true = success, false = failure |
Code example: DemoInterstitialAdActivity.java