The Auto Load mode is a one-stop request maintenance solution introduced by Taku. It can intelligently determine the preloading and caching timing of the next ad at multiple nodes based on the user's usage status and ad consumption progress. On the basis of meeting the developer's operational strategy, it avoids the failure risk of real-time ad data loading and wasted impression opportunities, and reduces the negative sentiment of users caused by ads not being loaded or being loaded poorly. With the Auto Load solution, developers can avoid repeated and tedious manual intervention in the request process, achieving immediate efficiency improvements. The SDK now supports the Auto Load mode.
(1) Initialization: Call ATInterstitialAutoAd.init(mainActivity,placementIds,listener) in the main Activity onCreate() and pass in the main Activity for Initialization. If you need to add more Auto Load Ad Placements later, please call addPlacementId(placementId) to add them.
(2) It is recommended to call entryAdScenario(placementId,scenarioId) after entering a displayable ad scenario to count the cache status of the current Ad Placement. For detailed usage of statistics, see Ad Scenarios for distinguishing data across different business scenarios.
(3) Displaying Ads: Before displaying, call isAdReady(placementId) to check if it is ready, then call show(activity,placement,listener) to display the ad.
ATInterstitialAutoAd: Management class for Auto Load Interstitial Ad.
| Method | Description |
|---|---|
| void init(Context context, String\[\] placementIds, ATInterstitialAutoLoadListener loadListener) | Initialization method for ATInterstitialAutoAd. After Initialization, ad loading will be automatically initiated for the specified Ad Placements. context: If the following platforms are integrated: GDT, Sigmob, Baidu, ironSource, Kidoz, Maio, Tabjoy, context must be an Activity. placementIds: Ad Placement IDs to enable Auto Load for (null can be passed). loadListener: Ad fill callback. See below for ATInterstitialAutoLoadListener description. |
Initialization:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// It is recommended to pass the Activity when calling onCreate in the main Activity for Initialization.
ATInterstitialAutoAd.init(MainActivity.this, new String[]{"your iv placementID1", "your iv placementID2"},autoLoadListener);
}
}
ATInterstitialAutoAd:
| Method | Description |
|---|---|
| boolean isAdReady(String placementId) | Determine whether the Ad Placement has a displayable ad. placementId: The Ad Placement ID to query. |
| void show(Activity activity, String placementId, ATInterstitialAutoEventListener eventListener) | Display the Interstitial Ad for this Ad Placement. activity: The Activity displaying the ad. placementId: The Ad Placement ID to display. eventListener: Interstitial Ad display callback. See below for ATInterstitialAutoEventListener description. |
| void show(Activity activity, String placementId, ATShowConfig showConfig, ATInterstitialAutoEventListener eventListener) | (Added in v6.3.10) Display the Interstitial Ad for this Ad Placement. activity: Same parameter meaning as above. placementId: Same parameter meaning as above. showConfig: Extra parameters that can be passed during display, as follows: 1. ATShowConfig#showCustomExt(String showCustomExt): Can pass custom parameters during display. The passed parameter will be returned via ATAdInfo#getShowCustomExt(). 2. ATShowConfig#scenarioId(String scenarioId): Can pass an ad scenario, same as show(Activity activity, String placementId, String scenario, ATInterstitialAutoEventListener eventListener). eventListener: Same parameter meaning as above. |
| void entryAdScenario(String placementId, String scenarioId) | Enter business scenario cache status statistics for the corresponding Ad Placement. placementId: Ad Placement ID. scenario: Ad display scenario. Scenario parameters can be created from the dashboard. For usage, please refer to Business Scenario Cache Status Statistics. |
Ad Display:
/*
To count scenario arrival rate, related info can be found at "https://help.takuad.com/docs/1RWLAv"
Call the “enter ad scenario” method when the ad triggering conditions are met, for example:
** If the ad scenario is to display an ad after a cleanup is finished, call it when the cleanup is finished;
* 1. First call "entryAdScenario"
* 2. Then call "isAdReady" to check if it is displayable
* 3. Finally call "show" to display
* 4. Passing the scenario ID into scenario will only result in data showing in the dashboard's scenario management.
*/
ATInterstitial.entryAdScenario("your iv placementID1", "your scenarioID"");
// Need to check if the Ad Placement is ready.
if(ATInterstitialAutoAd.isAdReady("your iv placementID1")){
ATInterstitialAutoAd.show(activity, "your iv placementID1","your scenarioID", autoEventListener);
}
ATInterstitialAutoAd:
| Method | Description |
|---|---|
| checkAdStatus(String placementId) | Get the status object ATAdStatusInfo for this Ad Placement. See below for the API description of the ATAdStatusInfo object. placementId: The Ad Placement ID to query. |
| checkValidAdCaches(String placementId) | Query the ATAdInfo objects of all cached info for this Ad Placement. placementId: The Ad Placement ID to query. |
| void addPlacementId(String... placementIds) | Add Ad Placements for Auto Load. placementIds: Ad Placement IDs to enable Auto Load for. |
| void removePlacementId(String... placementIds) | Remove Ad Placements that no longer need Auto Load. placementIds: Ad Placement IDs to disable Auto Load for. |
ATAdStatusInfo: Status object of the Ad Placement.
| Method | Description |
|---|---|
| boolean isLoading() | Determine whether the current Ad Placement is currently loading an ad. |
| boolean isReady() | Determine whether the current Ad Placement has a displayable ad. Same function as ATInterstitialAutoAd.isAdReady(). |
| getATTopAdInfo | Get the ad cache info ATAdInfo object with the highest priority for the current Ad Placement. ATAdInfo: Ad information object, can distinguish ad platforms, mainly contains ID info of third-party Mediation platforms. See ATAdInfo Info Description |
ATInterstitialAutoLoadListener: ATInterstitialAutoAd ad loading event callback listener:
| Method | Description |
|---|---|
| void onInterstitialAutoLoaded(String placementId) | Ad load success callback for the corresponding Ad Placement. placementId: The corresponding Ad Placement ID. |
| void onInterstitialAutoLoadFail(String placementId, AdError adError) | Ad load failure callback for the corresponding Ad Placement. placementId: Ad Placement ID. adError: Ad load failure info. You can get the full error info via AdError.getFullErrorInfo(). Please refer to AdError. |
Listener Example:
private static final ATInterstitialAutoLoadListener autoLoadListener = new ATInterstitialAutoLoadListener() {
@Override
public void onInterstitialAutoLoaded(String placementId) {
Log.i(TAG, "PlacementId:" + placementId + ": onInterstitialAutoLoaded");
}
@Override
public void onInterstitialAutoLoadFail(String placementId, AdError adError) {
Log.i(TAG, "PlacementId:" + placementId + ": onInterstitialAutoLoadFail:\n" + adError.getFullErrorInfo());
};
ATInterstitialAutoEventListener: ATInterstitialAutoAd ad event callback listener:
| Method | Description |
|---|---|
| void onInterstitialAdClicked(ATAdInfo atAdInfo) | Ad click callback. ATAdInfo: Ad information object, can distinguish ad platforms, mainly contains ID info of third-party Mediation platforms. See ATAdInfo Info Description |
| void onInterstitialAdShow(ATAdInfo atAdInfo) | Ad impression callback. Same parameter meaning as above. |
| void onInterstitialAdClose(ATAdInfo atAdInfo) | Ad close callback. Same parameter meaning as above. |
| void onInterstitialAdVideoStart(ATAdInfo atAdInfo) | Video ad playback start callback. Same parameter meaning as above. |
| void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) | Video ad playback end callback. Same parameter meaning as above. |
| void onInterstitialAdVideoError(AdError adError) | Video ad playback failure callback. adError: You can get the full error info via AdError.getFullErrorInfo(). Please refer to AdError. |
Listener Example:
private static final ATInterstitialAutoEventListener autoEventListener = new ATInterstitialAutoEventListener() {
@Override
public void onInterstitialAdClicked(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdClicked:" + adInfo.toString());
@Override
public void onInterstitialAdShow(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdShow:" + adInfo.toString());
}
@Override
public void onInterstitialAdClose(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdClose:" + adInfo.toString());
}
@Override
public void onInterstitialAdVideoStart(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdVideoStart:" + adInfo.toString());
}
@Override
public void onInterstitialAdVideoEnd(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdVideoEnd:" + adInfo.toString());
}
@Override
public void onInterstitialAdVideoError(AdError adError) {
Log.i(TAG, "onInterstitialAdVideoError:" + adError.getFullErrorInfo());
}
};
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// It is recommended to pass the Activity when calling onCreate in the main Activity for Initialization.
ATInterstitialAutoAd.init(MainActivity.this, new String[]{"placementId1", "placementId2"},autoLoadListener);
}
private static final ATInterstitialAutoLoadListener autoLoadListener = new ATInterstitialAutoLoadListener() {
@Override
public void onInterstitialAutoLoaded(String placementId) {
Log.i(TAG, "PlacementId:" + placementId + ": onInterstitialAutoLoaded");
}
@Override
public void onInterstitialAutoLoadFail(String placementId, AdError adError) {
Log.i(TAG, "PlacementId:" + placementId + ": onInterstitialAutoLoadFail:\n" + adError.getFullErrorInfo());
};
/*
To count scenario arrival rate, related info can be found at "https://docs.takuad.com/#/zh-cn/android/NetworkAccess/scenario/scenario"
Call the “enter ad scenario” method when the ad triggering conditions are met, for example:
** If the ad scenario is to display an ad after a cleanup is finished, call it when the cleanup is finished;
* 1. First call "entryAdScenario"
* 2. Then call "isAdReady" to check if it is displayable
* 3. Finally call "show" to display
* 4. Passing the scenario ID into scenario will only result in data showing in the dashboard's scenario management.
*/
ATInterstitial.entryAdScenario(placementId, "scenario");
// Need to check if the Ad Placement is ready.
if(ATInterstitialAutoAd.isAdReady("placementId1")){
ATInterstitialAutoAd.show(activity, "placementId1","scenario", autoEventListener);
}
private static final ATInterstitialAutoEventListener autoEventListener = new ATInterstitialAutoEventListener() {
@Override
public void onInterstitialAdClicked(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdClicked:" + adInfo.toString());
@Override
public void onInterstitialAdShow(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdShow:" + adInfo.toString()); }
@Override
public void onInterstitialAdClose(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdClose:" + adInfo.toString()); }
@Override
public void onInterstitialAdVideoStart(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdVideoStart:" + adInfo.toString()); }
@Override
public void onInterstitialAdVideoEnd(ATAdInfo adInfo) {
Log.i(TAG, "onInterstitialAdVideoEnd:" + adInfo.toString()); }
@Override
public void onInterstitialAdVideoError(AdError adError) {
Log.i(TAG, "onInterstitialAdVideoError:" + adError.getFullErrorInfo());
}
};
}
For detailed Interstitial Ad sample code, please refer to the InterstitialAdActivity class in Demo.