Menu

Manual loading

1. Introduction

Manual loading mode can satisfy developers who need flexible access.

1.1 Integration Recommendations

Note: The SDK will not hold advertising instances( ATInterstitial) and callback instance (ATInterstitialListener), so developers need to ensure that the advertising instance will not be recycled before the advertising ends to avoid callback loss

1.Loading ads:

    • After launching the application or game, pass ATInterstitial.load to load ads, please call the loading method in advance to request the ads (for example, start loading ads when the application starts), so that they can be displayed quickly when the ads need to be triggered
    • It is recommended to call entryAdScenario(placementId,scenarioId) after entering the displayable advertising scene to count the cache status of the current advertising space. For specific statistical instructions, you can view the advertising scene to distinguish different businesses. Scenario data

2.Display ads:

    • Determine whether isAdReady() is ready before displaying, and then call show for ad display when ready; if not, If it is better, initiate the ad loading and wait for the ad to load successfully; if you need to display the ad in the successful callback (onInterstitialAdLoaded), you must first determine that the current application is in the foreground before executing the display method, otherwise it may cause ads Display outside the application or failure to display properly;

3.Ad preloading:< /p>

   After the interstitial ad is displayed, there is no need in the callback of onInterstitialAdShow or onInterstitialAdClose isAdReadyjudgment, directly call load for preloading (helps to increase the display volume of higher priority advertising sources)

   You can refer to Automatically request ads to enable automatic request for ads (if preloading after display above is implemented, there is no need to enable it)

    ; It is recommended to use a fully automatic request scheme. For details, see the fully automatic loading mode description

   It is recommended to configure a preset strategy: improve the ad loading effect of the first cold start , for detailed instructions and access tutorials, see SDK preset strategy usage instructions

1.2 Notes

    • It is forbidden to execute the ad loading method in the onRewardedVideoAdFailed callback, otherwise it will cause a lot of useless requests and may cause the application to freeze

2.API description

2.1 Advertisement loading

ATInterstitial: Loading class for Interstitial ads

MethodParametersDescription
ATInterstitial( Context context, String interstitialTakuPlacementID)Interstitial advertising initialization method, where interstitialTakuPlacementID is created through the Taku background Interstitial advertising spaceobtained. context: If the following platforms are integrated: gdt、sigmob、Baidu, ironSource, Kidoz, Maio, Tabjoy, context must be Activity
setLocalExtra(MapSet local parameters
loadInitiate ad loading
load(Context context)< /td> Initiates ad loading. Developers can use the specified Context to load ads by calling this method


Ad loading:

//Note: The advertising object must be globally referenced. If the advertising object is a temporary variable, it may be reclaimed during the advertising loading process and unable to receive advertising event callbacks
ATInterstitial mInterstitialAd;

private void loadAd() {
    if (mInterstitialAd == null) {
        mInterstitialAd = new ATInterstitial(this, interstitialTakuPlacementID);
    }
    mInterstitialAd.load();
}


2.2 Advertising object

ATInterstitial:

MethodParametersDescription
checkAdStatus-Get the status object ATAdStatusInfo of the current advertising slot. The API description of the ATAdStatusInfo object is shown below
checkValidAdCaches-Query the ATAdInfo object ATAdInfo for all cached information of the current advertising slot : The information object of the advertisement can distinguish the advertising platform, mainly including the id information of the third-party aggregation platform See ATAdInfo information description

ATAdStatusInfo: The status object of the advertising slot

MethodParameterDescription
isLoading-Determine whether the current ad slot is loading ads
isReadyDetermine whether there are ads that can be displayed in the current ad slot , the same as the ATInterstitial.isAdReady() method
getATTopAdInfo-Get the ad cache information ATAdInfo object ATAdInfo with the highest priority in the current ad slot: The information object of the advertisement can distinguish the advertising platform, and mainly includes the id information of the third-party aggregation platform See ATAdInfo information description

2.3 Advertising Display

ATInterstitial:

MethodParametersDescription
isAdReady-Determine whether there are ads that can be displayed in the current Interstitial
show( Activity activity)Display Interstitial ads (recommended)
show(Activity activity, String scenario )(Deprecated since v6.3.10) Display Interstitial ads. The scenario refers to the advertising display scene, and the scene parameters can be created from the background. Please refer to Advertising scene
show(Activity activity, ATShowConfig showConfig)(v6.3.10+) Display Interstitial ads.

showConfig: You can pass in additional parameters during display, as follows 1.ATShowConfig#showCustomExt(String showCustomExt): You can pass in custom parameters during display, and the parameters passed in will be returned through ATAdInfo#getShowCustomExt()

2.ATShowConfig#scenarioId(String scenarioId): Advertising scenarios can be passed in, the same as getNativeAd(String scenario)
(static) entryAdScenario(String placementId, String scenarioId)Enter the current ad slot cache status statistics in the business scenario. The scenario refers to the advertising display scene (not required, null can be passed directly). Scenario parameters can be created from the background and please refer to Business scenario cache status statistics


Ad display:

private void showAd() {
   /*
     In order to calculate the scene arrival rate, relevant information can be consulted“ https://docs.toponad.com/#/zh -CN/android/NetworkAccess/scenario/scenario“

Call the "Enter Advertising Scene" method when the advertising triggering conditions are met, for example:

**If an advertisement pops up after the cleaning is completed, it will be called at the end of the cleaning;

*1. First call "entryAdScenario"

*2. Can calling "isAdReady" display

*3. Finally, call "show" to display

*4. Scenario ID is passed in to the backend scene management for data display

 
     */
    ATInterstitial.entryAdScenario("your iv placementID", "your scenarioID");
    if (mInterstitialAd.isAdReady()) {
        mInterstitialAd.show(activity,"your scenarioID");
    }
}


Pass in custom parameters when ad displaying:

Taku SDK v6.3.10 and above supports developers to pass in custom parameters during ad display. The custom parameters passed in during display are independent of the custom parameters passed in during load. Custom parameters passed in during presentation can be returned in the Taku SDK callback information.


2.4 Advertising Listening

ATInterstitial:

ParameterDescription
setAdListener(ATInterstitialListener listener)Set Interstitial advertising listening callback, where ATInterstitialListener is the interface class that needs to implement advertising event callback
setAdDownloadListener(ATAppDownloadListener listener)
setAdSourceStatusListener(ATAdSourceStatusListener listener)Set advertising source level event listening callback, where ATAdSourceStatusListener is the interface class that needs to implement advertising source level event callbackSee ATAdSourceStatusListener description


ATInterstitialListener: It is the event callback listener for Interstitial advertising:

MethodParameterDescription
onInterstitialAdLoaded-Ad loading success callback
onInterstitialAdLoadFail(AdError error)Ad loading failure callback, all error information can be obtained through AdError.getFullErrorInfo(), Please refer to AdError Note: It is prohibited to execute the advertising loading method in this callback for retry, otherwise it will cause many useless requests and may Will cause application lag
onInterstitialAdClicked(ATAdInfo atAdInfo)Ad click, where ATAdInfo is the information object of the ad ATAdInfo: ad The information object can distinguish the advertising platform, mainly including the id information of the third-party aggregation platform See ATAdInfo information description
onInterstitialAdShow(ATAdInfo atAdInfo)The meaning of the ad display callback parameters is the same as above It is recommended to call load in this callback to load the ad to facilitate the next ad display
onInterstitialAdClose(ATAdInfo atAdInfo)Ad closing callback,  The meaning of the parameters is the same as above
onInterstitialAdVideoStart(ATAdInfo atAdInfo)The video ad starts playing callback parameter has the same meaning as above
onInterstitialAdVideoEnd(ATAdInfo atAdInfo) The meaning of the video ad playback end callback parameters is the same as above
onInterstitialAdVideoError(AdError error)The meaning of the callback parameters for video ad playback failure is the same as above


Ad listening:

mInterstitialAd.setAdListener(new ATInterstitialListener() {
            @Override
            public void onInterstitialAdLoaded() {
            }

            @Override
            public void onInterstitialAdLoadFail(AdError adError) {
                //Note: It is prohibited to retry the loading method of advertisements in this callback, otherwise it will cause many useless requests and may cause the application to lag
                //AdError,please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
                Log.e(TAG, "onInterstitialAdLoadFail:" + adError.getFullErrorInfo());
            }

            @Override
            public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
            }

            @Override
            public void onInterstitialAdShow(ATAdInfo atAdInfo) {
                //ATAdInfo can distinguish between advertising platforms and obtain advertising space IDs for advertising platforms
                //please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_callback_access?id=callback_info
               //It is recommended to call load in this callback to load advertisements for the convenience of next advertisement display (isAdReady() is not required) 
                 mInterstitialAd.load();
            }

            @Override
            public void onInterstitialAdClose(ATAdInfo atAdInfo) {
            }

            @Override
            public void onInterstitialAdVideoStart(ATAdInfo atAdInfo) {
                
            }

            @Override
            public void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) {
            }

            @Override
            public void onInterstitialAdVideoError(AdError adError) {
                //AdError,please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
                Log.e(TAG, "onInterstitialAdVideoError:" + adError.getFullErrorInfo());
            }
        });

2.5 other monitoring

ATInterstitialExListener: Inherited from ATInterstitialListener, the method is the same as ATInterstitialListener, the additional callback description is as follows:

MethodParametersDescription
onDeeplinkCallback(ATAdInfo adInfo, boolean isSuccess)deeplink callback, for Adx, OnlineApi adsisSuccess: whether it is successful
onDownloadConfirm(Context context, ATAdInfo atAdInfo, View clickView, ATNetworkConfirmInfo networkConfirmInfo)(new in v5.7.70) Callback method when application ads are clicked to download. ATNetworkConfirmInfo: The callback information provided by the third-party advertising platform(Currently only GDTDownloadFirmInfo of Youlianghui) ATAdInfo: The information object of the advertisement, which can distinguish the advertising platform, mainly including the id information of the third-party aggregation platformSee ATAdInfo information description


ATAppDownloadListener: (Only supported by China SDK)Event callback monitoring for download status Currently only the following platforms are supported: Pangolin

MethodParametersDescription
onDownloadStart(ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName)Start download callback ATAdInfo: advertising information object, Can distinguish advertising platforms, mainly including the id information of third-party aggregation platforms See ATAdInfo information description totalBytes: total file size (unit: bytes) currBytes : The currently downloaded size (unit: bytes) fileName: file name appName: application name corresponding to the file
onDownloadUpdate(ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName)Download progress update callback parameters have the same meaning as above
onDownloadPause (ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName)The meaning of the pause download callback parameter is the same as above
onDownloadFinish(ATAdInfo adInfo, long totalBytes, String fileName, String appName)Download completion callback parameters have the same meaning as above
onDownloadFail(ATAdInfo adInfo, long totalBytes, long currBytes, String fileName, String appName)Download The meaning of the failure callback parameters is the same as above
onInstalled(ATAdInfo adInfo, String fileName, String appName)Apk installation completion callback parameters have the same meaning as above


3. Sample code

//Note: The advertising object must be globally referenced. If the advertising object is a temporary variable, it may be reclaimed during the advertising loading process and unable to receive advertising event callbacks
ATInterstitial mInterstitialAd;

private void loadAd() {
    if (mInterstitialAd == null) {
        mInterstitialAd = new ATInterstitial(this, interstitialTakuPlacementID);
        mInterstitialAd.setAdListener(new ATInterstitialListener() {
            @Override
            public void onInterstitialAdLoaded() {
            }

            @Override
            public void onInterstitialAdLoadFail(AdError adError) {
                //Note: It is prohibited to retry the loading method of advertisements in this callback, otherwise it will cause many useless requests and may cause the application to lag
                //AdError,please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
                Log.e(TAG, "onInterstitialAdLoadFail:" + adError.getFullErrorInfo());
            }

            @Override
            public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
            }

            @Override
            public void onInterstitialAdShow(ATAdInfo atAdInfo) {
                //ATAdInfo can distinguish between advertising platforms and obtain advertising space IDs for advertising platforms
                //please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_callback_access?id=callback_info
            }

            @Override
            public void onInterstitialAdClose(ATAdInfo atAdInfo) {
            }

            @Override
            public void onInterstitialAdVideoStart(ATAdInfo atAdInfo) {
                //It is recommended to call load in this callback to load advertisements for the convenience of next advertisement display (isAdReady() is not required)
                mInterstitialAd.load();
            }

            @Override
            public void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) {
            }

            @Override
            public void onInterstitialAdVideoError(AdError adError) {
                //AdError,please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
                Log.e(TAG, "onInterstitialAdVideoError:" + adError.getFullErrorInfo());
            }
        });
    }
    mInterstitialAd.load();
}
private void showAd() {
   /*
    In order to calculate the scene arrival rate, relevant information can be consulted“ https://docs.toponad.com/#/zh -CN/android/NetworkAccess/scenario/scenario“

Call the "Enter Advertising Scene" method when the advertising triggering conditions are met, for example:

**If an advertisement pops up after the cleaning is completed, it will be called at the end of the cleaning;

*1. First call "entryAdScenario"

*2. Can calling "isAdReady" display

*3. Finally, call "show" to display

*4. Scenario ID is passed in to the backend scene management for data display
     */
    ATInterstitial.entryAdScenario("your iv placementID", "your scenarioID");
    if (mInterstitialAd.isAdReady()) {
        mInterstitialAd.show(activity,"your scenarioID");
    }
}

For detailed interstitial ad sample code, please refer to: Demo's InterstitialAdActivity class


Previous
Interstitial ad
Next
Fully automatic loading
Last modified: 2025-05-30Powered by