Menu

Manual loading

1. Introduction

Manual loading mode can satisfy developers who need flexible access.

1.1 Integration suggestions

Note: The SDK will not hold ads Instance (ATRewardVideoAd) and callback instance (ATRewardVideoListener), so developers need to ensure that the ad instance will not be recycled before the ad ends to avoid callback loss

    1. Load ad:
      • After starting the application or game, use ATRewardVideoAd.load to load the advertisement. Please call the loading method in advance to request the advertisement (for example, start loading the advertisement when the application starts), so that it can be displayed quickly when the advertisement needs to be triggered< /li>
      • It is recommended to call entryAdScenario(placementId,scenarioId) after entering the scene where ads can be displayed to count the cache status of the current ad slot. Specific statistical instructions can be View Advertising scenarios to differentiate between different business scenarios
    2. Display ads:
      • Pre-display judgmentisAdReady()Whether it is ready, call show for ad display when ready; if it is not ready, initiate ad loading and wait for the ad to load successfully; if it is necessary to display the ad in the successful callback (onRewardedVideoAdLoaded) , you must first determine that the current application is in the foreground before executing the display method, otherwise it may cause the advertisement to be displayed outside the application or fail to display normally;
    3. Ad preloading:
      • After the rewarded video ad is displayed, there is no need in the callback of onRewardedVideoAdPlayStart isAdReady determines and directly calls load to preload  (helps to improve priority The impression volume of higher-level advertising sources)
      • Please refer to Automatically request ads, turn on automatic request for ads (If preloading after display above has been implemented, there is no need to turn it on)

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

1.2 Notes

   1. 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 p>

   2. The userId and extraData passed in by setLocalExtra will only take effect for the next and subsequent rewarded video loads. , does not take effect on cached rewarded video ads

2. API description

2.1 Advertisement loading

ATRewardVideoAd: Loading class for RewardedVideo ads

method ParameterDescription
ATRewardVideoAd(Context context, String rewardTopOnPlacementID)Initialization method of RewardedVideo advertisement , where rewardTopOnPlacementID is obtained by creating rewarded video ad slot through TopOn backend.
context: If the following platforms are integrated: Ironsource, Kidoz, Maio, Tapjoy, context must be Activity
setLocalExtra(Map<String, Object> map)
load-Initiate ad loading
load(Context context)Initiates ad loading. Developers can call This method uses the specified Context to load ads

2.2 Local parameters

ATAdConst.KEY: LocalExtra local parameter predefined Key value

method Description
USER_ID(optional) used for server incentives, user unique ID
USER_CUSTOM_DATA(optional) used for server incentives, user-defined data


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
ATRewardVideoAd mRewardVideoAd;
private void loadAd() {
    if (mRewardVideoAd == null) {
        mRewardVideoAd = new ATRewardVideoAd(this, rewardTopOnPlacementID);
    }
    String userid = "test_userid_001";
    String userdata = "test_userdata_001";
    Map<String, Object> localMap = new HashMap<>();
    localMap.put(ATAdConst.KEY.USER_ID, userid);
    localMap.put(ATAdConst.KEY.USER_CUSTOM_DATA, userdata);
    //Pass custom parameters when loading, and after filling the ad source, the custom parameters will be saved and returned during display. Applicable scenario: Similar to preventing cheating when passing in session information
    mRewardVideoAd.setLocalExtra(localMap);
    mRewardVideoAd.load();
}

Pass custom parameters when loading. After the ad source is filled, the custom parameters will be saved together with the ad source cache. If you want to pass in custom parameters when  ad displaying, please update TopOn SDK v6.3.10 and above.


2.3 Advertising object

ATRewardVideoAd:

MethodParametersDescription
checkAdStatus-Get the status object ATAdStatusInfo of the current advertising slot. See the API description of the ATAdStatusInfo object below
checkValidAdCaches-Query all cached information of the current ad slot ATAdInfo object ATAdInfo: advertising information object, which can distinguish advertising platforms. It mainly contains the id information of third-party aggregation platforms See ATAdInfo Information description

ATAdStatusInfo: Status object of the advertising slot

MethodParametersDescription
isLoading-Determine whether the current ad slot is loading ads
isReady -Determine whether there are ads that can be displayed in the current ad slot, and ATRewardVideoAd.isAdReady() The methods have the same effect
getATTopAdInfo-Get the ad cache information with the highest priority in the current ad slot ATAdInfo object ATAdInfo: the information object of the ad, which can distinguish the advertising platform, mainly including the id information of the third-party aggregation platform See ATAdInfo information description

2.4 Advertisement display

ATRewardVideoAd:

methodParameterDescription
isAdReady-Determine whether there are ads that can be displayed in the current RewardedVideo< /td>
show(Activity activity)Show RewardedVideo ads (recommended)
show(Activity activity, String scenario)(Deprecated since v6.3.10) Display RewardedVideo 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 RewardedVideo 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
     */            
       ATRewardVideoAd.entryAdScenario("your rv placementID", "your scenarioID");
    if (mRewardVideoAd.isAdReady()) {
        mRewardVideoAd.show(activity,"your scenarioID");
    }
} 


Pass in custom parameters when ad displaying:

TopOn 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 TopOn SDK callback information. At the same time, TopOn's server-to-server Rewarded callback also supports returning custom parameters passed in during ad display.


2.5 Advertising Monitoring

ATRewardVideoAd:

MethodParametersDescription
setAdListener(ATRewardVideoListener listener)Set the RewardedVideo ad listening callback, where ATRewardVideoListener is the interface class that needs to implement the ad event callback
setAdDownloadListener(ATAppDownloadListener listener)Set download status listening callback
listener: event callback listening for download status

Currently only supports the following Platform: Pangolin
setAdSourceStatusListener(ATAdSourceStatusListener listener)SettingsAd source level event listening callback, where ATAdSourceStatusListener is the interface class that needs to implement the advertising source level event callback See ATAdSourceStatusListener description


ATRewardVideoListener: Event callback monitoring for RewardedVideo ads:

MethodParametersDescription
onRewardedVideoAdLoaded-Ad loading success callback
onRewardedVideoAdFailed(AdError error)Ad loading failure callback, you can pass AdError .getFullErrorInfo() to obtain all error information, please refer to AdError Note: Callbacks are prohibited here Retry the loading method of the advertisement in the execution, otherwise it will cause a lot of useless requests and may cause the application to freeze
onRewardedVideoAdPlayStart( ATAdInfo atAdInfo)Ad start playback callback (i.e. rewarded video display callback) ATAdInfo: Advertising Information object, which can distinguish advertising platforms, mainly includes the id information of third-party aggregation platforms See ATAdInfo information description it is recommended to call load in this callback The loading of advertisements facilitates the display of the next advertisement
onRewardedVideoAdPlayEnd(ATAdInfo atAdInfo)The meaning of the ad playback end callback parameter is the same as above
onRewardedVideoAdPlayFailed(AdError errorCode, ATAdInfo atAdInfo)The meaning of callback parameters for ad playback failure is the same as above
onReward(ATAdInfo atAdInfo)This callback will be triggered when the incentive is issued , It is recommended that developers issue rewards in this callback, usually before onRewardedVideoAdClosed The meaning of the parameters is the same as above
onRewardedVideoAdClosed( ATAdInfo atAdInfo)Ad closing callback, The meaning of the parameters is the same as above
onRewardedVideoAdPlayClicked(ATAdInfo atAdInfo)The meaning of advertising click parameters is the same as above

Advertisement listening:

//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
        mRewardVideoAd.setAdListener(new ATRewardVideoListener() {
            @Override
            public void onRewardedVideoAdLoaded() {
            }
            @Override
            public void onRewardedVideoAdFailed(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,请参考 https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
                Log.e(TAG, "onRewardedVideoAdFailed:" + adError.getFullErrorInfo());
            }
            @Override
            public void onRewardedVideoAdPlayStart(ATAdInfo adInfo) {
                //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)
                mRewardVideoAd.load();
            }
            @Override
            public void onRewardedVideoAdPlayEnd(ATAdInfo atAdInfo) {
            }
            @Override
            public void onRewardedVideoAdPlayFailed(AdError adError, ATAdInfo atAdInfo) {
                //AdError,please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
                Log.e(TAG, "onRewardedVideoAdPlayFailed:" + adError.getFullErrorInfo());
            }
            @Override
            public void onRewardedVideoAdClosed(ATAdInfo atAdInfo) {
            }
            @Override
            public void onReward(ATAdInfo atAdInfo) {
                //Suggest issuing rewards in this callback, usually before onRewardedVideoAdClosed
            }
            @Override
            public void onRewardedVideoAdPlayClicked(ATAdInfo atAdInfo) {
            }
        });

2.6 Other monitoring

ATRewardVideoExListener:Inherited from ATRewardVideoListener, same method as

ATRewardVideoListener,The additional callback instructions are as follows:


MethodParametersDescription
onDeeplinkCallback(ATAdInfo atAdInfo, boolean isSuccess)Deeplink callback for Adx and OnlineApi advertisements

IsSuccess: Is it successful
onDownloadConfirm(Context context, ATAdInfo atAdInfo, View clickView, ATNetworkConfirmInfo networkConfirmInfo)Callback method when clicking download for application advertisements.

ATNetworkConfirmInfo: Callback information provided by third-party advertising platforms (currently only available in GDTDownloadFirmInfo from Youlianghui)

ATAdInfo: The information object of an advertisement, which can distinguish between advertising platforms and mainly includes the ID information of third-party aggregation platforms. Please refer to the ATAdInfo information description
onRewardedVideoAdAgainPlayStart(ATAdInfo atAdInfo)Looking at the start playback callback of another advertisement

The parameter meaning refers to ATRewardVideoListener
onRewardedVideoAdAgainPlayEnd(ATAdInfo atAdInfo)Watch the playback end callback of another advertisement

The parameter meaning refers to ATRewardVideoListener
onRewardedVideoAdAgainPlayFailed(AdError errorCode, ATAdInfo atAdInfo)Looking at another advertisement's playback failure callback

The parameter meaning refers to ATRewardVideoListener
onRewardedVideoAdAgainPlayClicked(ATAdInfo atAdInfo)Looking at the click callback of another advertisement

The parameter meaning refers to ATRewardVideoListener
onAgainReward(ATAdInfo atAdInfo)Take another look at the incentive callback for advertising issuance

The parameter meaning refers to ATRewardVideoListener


ATAppDownloadListener: (Only supported by SDK in China) Event callback listening for download status
Currently, only the following platforms are supported:csj


MethodParametersDescription
onDownloadStart(ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName)Start downloading callback

ATAdInfo: The information object of an advertisement, which can distinguish between advertising platforms and mainly includes the ID information of third-party aggregation platforms. Please refer to the ATAdInfo information description

TotalBytes: Total file size (in bytes)

CurrBytes: The current downloaded size (in bytes)

FileName: File name

AppName: The application name corresponding to the file
onDownloadUpdate(ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName)Download progress update callback

The parameter meaning is the same as above
onDownloadPause(ATAdInfo atAdInfo, long totalBytes, long currBytes, String fileName, String appName)Pause download callback

The parameter meaning is the same as above
onDownloadFinish(ATAdInfo adInfo, long totalBytes, String fileName, String appName)Download completion callback

The parameter meaning is the same as above
onDownloadFail(ATAdInfo adInfo, long totalBytes, long currBytes, String fileName, String appName)Download failure callback

The parameter meaning is the same as above
onInstalled(ATAdInfo adInfo, String fileName, String appName)APK installation completion callback

The parameter meaning is the same 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
ATRewardVideoAd mRewardVideoAd;
private void loadAd() {
    if (mRewardVideoAd == null) {
        mRewardVideoAd = new ATRewardVideoAd(this, rewardTopOnPlacementID);
        mRewardVideoAd.setAdListener(new ATRewardVideoListener() {
            @Override
            public void onRewardedVideoAdLoaded() {
            }
            @Override
            public void onRewardedVideoAdFailed(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, "onRewardedVideoAdFailed:" + adError.getFullErrorInfo());
            }
            @Override
            public void onRewardedVideoAdPlayStart(ATAdInfo adInfo) {
                //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)
                mRewardVideoAd.load();
            }
            @Override
            public void onRewardedVideoAdPlayEnd(ATAdInfo atAdInfo) {
            }
            @Override
            public void onRewardedVideoAdPlayFailed(AdError adError, ATAdInfo atAdInfo) {
                //AdError,please refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
                Log.e(TAG, "onRewardedVideoAdPlayFailed:" + adError.getFullErrorInfo());
            }
            @Override
            public void onRewardedVideoAdClosed(ATAdInfo atAdInfo) {
            }
            @Override
            public void onReward(ATAdInfo atAdInfo) {
                //Suggest issuing rewards in this callback, usually before onRewardedVideoAdClosed
            }
            @Override
            public void onRewardedVideoAdPlayClicked(ATAdInfo atAdInfo) {
            }
        });
    }
    String userid = "test_userid_001";
    String userdata = "test_userdata_001";
    Map<String, Object> localMap = new HashMap<>();
    localMap.put(ATAdConst.KEY.USER_ID, userid);
    localMap.put(ATAdConst.KEY.USER_CUSTOM_DATA, userdata);
    //Pass custom parameters when loading, and after filling the ad source, the custom parameters will be saved and returned during display. Applicable scenario: Similar to preventing cheating when passing in session information
    mRewardVideoAd.setLocalExtra(localMap);
    mRewardVideoAd.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
     */            
       ATRewardVideoAd.entryAdScenario("your rv placementID", "your scenarioID");
    if (mRewardVideoAd.isAdReady()) {
        mRewardVideoAd.show(activity,"your scenarioID");
    }
} 

For detailed rewarded video ad sample code, please refer to: RewardVideoAdActivity class of Demo

Previous
Rewarded Video Ad
Next
Fully automatic loading
Last modified: 2025-05-30Powered by