💡Tips:
- To implement a custom Interstitial Ad Adapter, you need to extend
com.anythink.interstitial.unitgroup.api.CustomInterstitialAdapter
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 Interstitial Ads 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: Parameters of customization passed during this load, available through the localExtra parameter which includes key-value pairs passed via ATInterstitial#setLocalExtra() . |
boolean isAdReady() | Determine if the custom network's Interstitial Ad is ready |
void show(Activity activity) | Implement the logic to display the customized network's Interstitial Ad |
2. Interstitial Ads Event Callbacks
Use the CustomInterstitialAdapter's CustomInterstitialEventListener
member variable to implement ad event callbacks.
Method | Description |
void onInterstitialAdVideoStart() | Called when the ad video starts playing |
void onInterstitialAdVideoEnd() | Called when the ad video finishes playing |
void onInterstitialAdVideoError(String errorCode, String errorMsg) | Called when the ad video fails to play errorCode: Error code information errorMsg: Detailed error information |
void onInterstitialAdClose() | Called when the ad page is closed |
void onInterstitialAdClicked() | Called when the ad is clicked |
void onInterstitialAdShow() | Called when the ad page is opened |
⚠️Note: When using the
CustomInterstitialEventListener
member variable, ensure to handle null checks.
3. Sample code
For detailed code, please refer to FacebookInterstitialAdapter.java in the Demo.