Menu

Fully automatic loading

1. Introduction to fully automatic loading of rewarded video ads

Fully automatic loading mode is a one-stop request maintenance solution launched by TopOn, which can be based on user usage Status and advertisement consumption progress, multi-node intelligently determines the preloading and caching timing of the next advertisement. On the basis of satisfying the developer's operation strategy, it avoids the risk of failure in real-time loading of advertising data and wasted display opportunities, and alleviates users' negative emotions caused by ads not loading or loading not smoothly. Through fully automatic loading of solutions, developers can avoid repeated and cumbersome manual intervention request solutions, and efficiency improvements are immediate. SDK begins to support fully automatic loading mode.

1.1 Integration recommendations

    1. Call ATRewardVideoAutoAd. init (mainActivity, placementIds, listener) in the main Activity onCreat() and pass it to the main Activity for initialization. If you need to add fully automatic ad loading in the future, please call addPlacementId (placementId) to add it
    2. It is recommended to call < after entering a scene where ads can be displayed. strong>entryAdScenario(placementId,scenarioId)Stats the cache status of the current advertising space. For specific statistical instructions, you can view the data of advertising scenarios to distinguish different business scenarios
    3. Display ads: Determine whether isAdReady(placementId) is ready before displaying, and then call          show(activity,placement,listener) when ready. strong>Perform ad display
    4. Server callback: If you need to support server callback (S2S), pass in userId, extraData strong>Please set it at the following timing: Note:

        (1) Fully automatic stimulation The video implements automatic loading logic internally, so please avoid performing ad display directly in the onRewardVideoAutoLoaded callback

        (2) If the ad slot is set to fully automatic loading, do not call ATRewardVideoAd (ordinary rewarded video) .load() to load the ad

1.2 Notes:

   1. onReward() will be called back when the incentive video is issued. Developers can < strong>onRewardDistribute incentives to users during callbacks

   2. Fully automatic loading of incentive videos supports the incentive delivery mechanism of server callback (S2S), and also supports various advertising platforms. For the server callback function, please refer to the Incentive Video Server Incentive (S2S) Instructions

2.API Instructions

2.1 Advertising Initialization

ATRewardVideoAutoAd: Fully automatic loading of rewarded video ads Management class

MethodParametersDescription
init(Context context , String[] placementIds, ATRewardVideoAutoLoadListener loadListener)ATRewardVideoAutoAd advertising initialization method, after initialization Automatically initiate ad loading for designated ad slots
context: If the following platforms are integrated: Ironsource, Kidoz, Maio, Tapjoy, context is required Is Activity
placementIds: Enable fully automatic loading of the advertising slot Id (can pass null)
loadListener: Ad filling callback
setLocalExtra(String placementId, Map<String, Object> localExtra)Set local parameters for the specified advertising slot
placementId: Advertising slot Id
localExtra: local parameters, key throughATAdConst. KEYGet it


Initialization:

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //It is recommended to pass in the activity for initialization when creating the main activity onCreate
        ATRewardVideoAutoAd.init(MainActivity.this, new String[]{"your rv placementID1", "your rv placementID2"},autoLoadListener);
    }
}

2.2 Local parameters

ATAdConst.KEY: LocalExtra local parameter predefined Key value

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

Server callback:

//Set server callback localExtra information
private static void setPlacementIdLocalExtra(String placementId) {
    String userid = "test_userid_001";
    String userdata = "test_userdata_001_" + placementId + "_" + System.currentTimeMillis();
    Map<String, Object> localMap = new HashMap<>();
    localMap.put(ATAdConst.KEY.USER_ID, userid);
    localMap.put(ATAdConst.KEY.USER_CUSTOM_DATA, userdata);
    //Effective from the next ad loading
    ATRewardVideoAutoAd.setLocalExtra(placementId, localMap);
}

//Setting timing 1: Before initialization or adding advertising space
setPlacementIdLocalExtra("your rv placementID1");//Before initialization, set localExtra for the specified advertising space
ATRewardVideoAutoAd.init(this, new String[]{"your rv placementID1", "your rv placementID2"}, autoLoadListener);
//ATRewardVideoAutoAd.addPlacementId("placementId1");

//Set timing 2: After filling the advertisement
private static ATRewardVideoAutoLoadListener autoLoadListener = new ATRewardVideoAutoLoadListener() {
    @Override
    public void onRewardVideoAutoLoaded(String placementId) {
        //If you need to update localExtra, set it here and it will take effect from the next load
        setPlacementIdLocalExtra(placementId);
    }

    @Override
    public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {
    }
};

2.3 Advertisement display

ATRewardVideoAutoAd:




MethodParametersDescription
isAdReady(String placementId)Determine whether there are ads that can be displayed in this ad slot
placementId: the ad to be queried Bit Id
show(Activity activity, String placementId, ATRewardVideoAutoEventListener eventListener)(Deprecated since v6.3.10) Display this ad slot rewarded video ad activity: the Activity to display the ad
placementId: the ad slot Id to be displayed eventListener: rewarded video Ad display and incentive callback, ATRewardVideoAutoEventListener description is shown below
show (Activity activity, String placementId, ATShowConfig showConfig, ATRewardVideoAutoEventListener eventListener)(v6.3.10+) Display this ad slot rewarded video ad activity: the Activity to display the ad
placementId: the ad slot Id to be displayed

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)

eventListener: rewarded video Ad display and incentive callback, ATRewardVideoAutoEventListener description is shown below
entryAdScenario(String placementId, String scenarioId)Cache status statistics of the corresponding advertising space entering the business scenario placementId: advertising space Id scenario: advertising display scenario, which can be obtained from For background creation scenario parameters and usage, please refer to Business scenario cache status statistics


Ad display:

        /*
     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");
//Need to determine if the advertising space is ready
if(ATRewardVideoAutoAd.isAdReady("your rv placementID")){
    ATRewardVideoAutoAd.show(activity, "your rv placementID", "your scenarioID",autoEventListener);
}


2.4 Ad object

ATRewardVideoAutoAd:

MethodParameterDescription
checkAdStatus(String placementId)Get the status object ATAdStatusInfo of the advertising slot. The API description of the ATAdStatusInfo object is shown below
placementId: the advertising slot Id to be queried
checkValidAdCaches(String placementId)query the ATAdInfo object for all cached information of this ad slot
placementId: the advertising space Id to be queried
addPlacementId(String... placementIds)Add advertising space that needs to be loaded automatically
placementIds: Advertising space Id that needs to be loaded automatically
removePlacementId(String... placementIds)Remove ad slots that do not need to be loaded automatically
placementIds: ad slots that do not need to be loaded automatically

ATAdStatusInfo: Status object of the advertising slot

MethodParameterDescription< /th>
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, which has the same effect as the ATRewardVideoAd.isAdReady() method
getATTopAdInfo-Get the highest priority of the current advertising space Advertising cache information ATAdInfo object
ATAdInfo: advertising information object, which can distinguish advertising platforms, mainly including the id information of third-party aggregation platforms See ATAdInfo information description

2.5 Advertising Monitoring

ATRewardVideoAutoLoadListener: Loading event callback monitoring of ATRewardVideoAutoAd advertisement:

MethodParametersDescription
onRewardVideoAutoLoaded(String placementId)Corresponding ad slot ad load callback successfully
placementId: Corresponding ad slot Id
onRewardVideoAutoLoadFail(String placementId, AdError adError)Corresponding ad loading failure callback
placementId: Advertising Id
adError: Ad loading failure information, all error information can be obtained through AdError.getFullErrorInfo(), please refer to AdError


Listening example:

private static ATRewardVideoAutoLoadListener autoLoadListener = new ATRewardVideoAutoLoadListener() {
    @Override
    public void onRewardVideoAutoLoaded(String placementId) {
     
    }

    @Override
    public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {
    }
}; 

ATRewardVideoAutoEventListener: ATRewardVideoAutoAd advertisement Event callback monitoring:

MethodParametersDescription
onRewardedVideoAdPlayStart( ATAdInfo atAdInfo)Ad start playing callback (i.e. rewarded video display callback)
ATAdInfo : 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
onRewardedVideoAdPlayEnd(ATAdInfo atAdInfo)Ad playback end callback
The parameters have the same meaning as above
onRewardedVideoAdPlayFailed(AdError errorCode, ATAdInfo atAdInfo) Ad playback failure callback
atAdInfo: Parameter meaning is the same as above
errorCode: Advertisement Display failure information, you can obtain all error information through AdError.getFullErrorInfo(), please refer to AdError
onReward(ATAdInfo atAdInfo)Issue incentives This callback will be triggered when 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 )Ad click
The meaning of the parameters is the same as above
onDeeplinkCallback(ATAdInfo atAdInfo, boolean isSuccess)deeplink callback, for Adx and OnlineApi ads
isSuccess: whether it was successful
onDownloadConfirm(Context context, ATAdInfo atAdInfo, View clickView, ATNetworkConfirmInfo networkConfirmInfo)Callback method when the application advertisement is clicked to download.
atAdInfo: The parameter meaning is the same as above
networkConfirmInfo: callback information provided by the third-party advertising platform(Currently only the callback information provided by Youlianghui GDTDownloadFirmInfo)
onRewardedVideoAdAgainPlayStart (ATAdInfo atAdInfo)Pangolin watches the start play callback of another advertisement
Parameter meaning reference onRewardedVideoAdPlayStart
onRewardedVideoAdAgainPlayEnd(ATAdInfo atAdInfo)Pangolin watches the end of another advertisement Callback
Parameter meaning reference onRewardedVideoAdPlayEnd
onRewardedVideoAdAgainPlayFailed(AdError errorCode, ATAdInfo atAdInfo)Pangolin watches another ad's playback failure callback
Parameter meaning reference onRewardedVideoAdPlayFailed
onRewardedVideoAdAgainPlayClicked(ATAdInfo atAdInfo)Pangolin looks at another ad click Callback
Parameter meaning reference onRewardedVideoAdPlayClicked
onAgainReward(ATAdInfo atAdInfo)Pangolin watches another advertisement and issues incentive callback
Parameter meaning refer to onReward


3. Sample code

//Set server callback localExtra information
private static void setPlacementIdLocalExtra(String placementId) {
    String userid = "test_userid_001";
    String userdata = "test_userdata_001_" + placementId + "_" + System.currentTimeMillis();
    Map<String, Object> localMap = new HashMap<>();
    localMap.put(ATAdConst.KEY.USER_ID, userid);
    localMap.put(ATAdConst.KEY.USER_CUSTOM_DATA, userdata);
    //Effective from the next ad loading
    ATRewardVideoAutoAd.setLocalExtra(placementId, localMap);
}

//Setting timing 1: Before initialization or adding advertising space
setPlacementIdLocalExtra("your rv placementID1");//Before initialization, set localExtra for the specified advertising space
ATRewardVideoAutoAd.init(this, new String[]{"your rv placementID1", "your rv placementID2"}, autoLoadListener);
//ATRewardVideoAutoAd.addPlacementId("placementId1");

//Set timing 2: After filling the advertisement
private static ATRewardVideoAutoLoadListener autoLoadListener = new ATRewardVideoAutoLoadListener() {
    @Override
    public void onRewardVideoAutoLoaded(String placementId) {
        //If you need to update localExtra, set it here and it will take effect from the next load
        setPlacementIdLocalExtra(placementId);
    }

    @Override
    public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {
    }
};
    /*
     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 placementID1", "your scenarioID");
//Need to determine if the advertising space is ready
if(ATRewardVideoAutoAd.isAdReady("your rv placementID1")){
    ATRewardVideoAutoAd.show(activity, "your rv placementID1", "your scenarioID",autoEventListener);
}

For detailed rewarded video ad sample code, please refer to:Demo'sRewardVideoAdActivityClass

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