💡Tips:
- To implement a custom Banner Ad Adapter, you need to extend
com.anythink.banner.unitgroup.api.CustomBannerAdapterand override all abstract methods. In the respective methods, you should call the ad platform's API and use the class member variablemLoadListenerto callback the result of the ad loading, and usemImpressionListenerto callback the results of ad display, clicks, and closings.
1. Additional Abstract Methods for Banner 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: Custom parameters passed during this load, available through the localExtra parameter which includes key-value pairs passed via ATBannerView#setLocalExtra(). |
| View getBannerView() | need to return an object with a successfully loaded BannerView |
2. Banner Ads Event Callbacks
Use the CustomBannerAdapter's CustomBannerEventListener member variable to implement ad event callbacks.
| Method | Description |
| void onBannerAdClicked() | Called when the ad is clicked |
| void onBannerAdShow() | Called when the ad is displayed |
| void onBannerAdClose() | Called when the ad is closed |
⚠️Note: When using the
CustomBannerEventListenermember variable, ensure to handle null checks.
3. Sample code
For detailed code, please refer to FacebookBannerAdapter.java in the Demo.