💡Tips
- To implement a custom reward video Adapter, you need to extend
com.anythink.rewardvideo.unitgroup.api.CustomRewardVideoAdapter
and override all abstract methods. In the respective methods, you should call the ad platform's API and use the class member variablemLoadListener
to callback the result of the ad loading, and usemImpressionListener
to callback the results of ad display, clicks, and closings.
1. Additional Abstract Methods for Reward Ad Implementation
Method | Description |
void loadCustomNetworkAd(Context context, Map serverExtra, Map localExtra) | Implement the ad loading logic for the custom network context: The context passed to ATReward, VideoAd, ATInterstitial, ATNative, ATBannerView, ATSplashAd (Note: For splash ads, the context type is Activity). serverExtra: Custom parameters configured on the server. Key-value pairs from the JSON string configured in the TopOn backend can be retrieved through the serverExtra parameter. localExtra: Custom parameters passed during this load, available through the localExtra parameter which includes key-value pairs passed via ATRewardVideoAd#setLocalExtra() . |
boolean isAdReady() | Determine if the custom network's reward video ad is ready |
void show(Activity activity) | Implement the logic to display the custom network's reward video |
2. Reward Ad Event Callbacks
Use the CustomRewardVideoAdapter's CustomRewardedVideoEventListener
member variable to implement ad event callbacks.
method | Description |
void onRewardedVideoAdPlayStart() | Called when the ad video starts playing |
void onRewardedVideoAdPlayEnd() | Called when the ad video finishes playing |
void onRewardedVideoAdPlayFailed(String errorCode, String errorMsg) | Called when the ad video fails to play errorCode: Error code information errorMsg: Detailed error information |
void onRewardedVideoAdClosed() | Called when the ad page is closed |
void onRewardedVideoAdPlayClicked() | Called when the ad is clicked |
void onReward() | Called when the reward is granted to the user |
⚠️Note: When using the
CustomRewardedVideoEventListener
member variable, ensure to handle null checks.
3. Sample code
For detailed code, please refer to FacebookRewardVideoAdapter.java in the Demo.