Menu

Base Flow

For a detailed example of implementing a custom Adapter, refer to: Taku Demo

1. Class Descriptions for Implementing Each Ad Format

Developers need to inherit the class corresponding to the required ad format (see the table below) and override all abstract methods. In the corresponding methods, call the ad platform's API, callback the load result through the class member variable mLoadListener, and callback ad impression, click, close, and other event results through the class member variable mImpressionListener.

Ad Format Class Name
Rewarded Video com.anythink.rewardvideo.unitgroup.api.CustomRewardVideoAdapter
Interstitial Ad com.anythink.interstitial.unitgroup.api.CustomInterstitialAdapter
Banner Ad com.anythink.banner.unitgroup.api.CustomBannerAdapter
Native Ad com.anythink.nativead.unitgroup.api.CustomNativeAdapter
Splash Ad com.anythink.splash.unitgroup.api.CustomSplashAdapter

See how to create a Custom Adapter in the Taku dashboard

If you need to implement Bidding functionality using a custom Adapter, please check: Custom Advanced Configuration

2. Implementation of Common Abstract Methods and Ad Loading Event Callbacks

2.1 Implementation of Common Abstract Methods

Abstract Method Parameter Description Return Value Purpose Required Description
loadCustomNetworkAd Context context: Context Map serverExtra: Custom parameters configured on the server side Map localExtra: Custom parameters passed for this load void Implement the loading logic for the custom ad platform's ads. Yes context parameter: Corresponds to the context value passed to ATRewardVideoAd, ATInterstitial, ATNative, ATBannerView, or ATSplashAd. For Splash Ads, the context type is Activity; for Rewarded Video, Interstitial, Native (Info Feed) Ads, and Banner Ads, the context type depends on the Context passed to ATRewardVideoAd, ATInterstitial, ATNative, ATBannerView. serverExtra parameter: The key-value pairs in the JSON string configured in the Taku dashboard can all be obtained through the serverExtra parameter. Custom key-value pairs will transparently pass the configured placement ID (key=slot_id) by default. localExtra parameter: The key-value pairs passed through methods such as ATRewardVideoAd#setLocalExtra(), ATInterstitial#setLocalExtra(), ATNative#setLocalExtra(), ATBannerView#setLocalExtra(), etc., can all be obtained through the localExtra parameter.
destory - void Implement the destruction logic for the custom ad platform. Yes The Taku SDK will internally call this method at the appropriate time to destroy the ad platform's resources.
getNetworkPlacementId - void Provide the ad placement ID of the custom ad platform for this load. Yes Used for the ATAdInfo object in Taku SDK callback methods and related internal logic, etc.
getNetworkSDKVersion - void Provide the SDK version of the custom ad platform for this load. Yes Used for the ATAdInfo object in Taku SDK callback methods and related internal logic, etc.
setUserDataConsent Context context: Context boolean isConsent: Whether the user has authorized isEUTraffic: Whether it is the EU region boolean Provide the user's authorization status and EU information to the custom ad platform to implement GDPR settings. (Return true if implemented. Taku will use it for statistical recording.) No (Recommended to implement for releases in the EU region) -
getNetworkInfoMap - Map Provide custom information for the custom ad. No In this method, you can create a Map and add some extra information to this Map and return it. Developers can ultimately obtain this extra information by calling the ATAdInfo.getExtInfoMap() method through the ATAdInfo object in each Taku SDK callback method.

2.2 Callbacks for Common Ad Loading Events

Use the member variable ATCustomLoadListener in the Adapter to implement callbacks for ad loading results.

Callback Method Parameter Description Description
onAdCacheLoaded BaseAd... baseAds: Mainly used for calling back ad objects for Native Ads. Other ad formats do not need to add parameter callbacks. When ad content and creative materials are loaded successfully, call this method to notify the Taku SDK. Eventually, the Taku SDK will call back the load success method to notify the developer.
onAdLoadError String errorCode: Error code info String errorMsg: Detailed error info When ad loading fails, call this method to notify the Taku SDK. Eventually, the Taku SDK will call back the load failure method to notify the developer (errorCode and errorMsg will be encapsulated in the AdError object in the Taku SDK callback method).

Note: When using the member variable ATCustomLoadListener, null-check handling is required, because the Mediation SDK may internally reclaim this Listener object.

3. Usage and Notes for Custom Ad Platform Adapters

3.1 Usage Flow

• Developers only need to inherit the relevant classes and override the relevant methods. All methods in the custom Adapter do not need to be called by the developer. When the Ad Source for the custom ad platform is configured under the Ad Placement in the Taku dashboard, the SDK will internally call the relevant methods in the custom Adapter at the appropriate time.

• The developer calls the Taku SDK's load API to load an ad. The Taku SDK will create an instance of the custom Adapter class through reflection based on the class name configured in the dashboard, and call loadCustomNetworkAd() to request the ad. The loading result of the custom ad platform's ad needs to notify the Taku SDK by calling the methods of ATCustomLoadListener (onAdCacheLoaded, onAdLoadError). Eventually, the Taku SDK will notify the developer through the Taku callback methods.

• The parameters needed for loading ads on the custom ad platform (AppID, AppKey, PlacementID, etc.) should be configured in JSON string format in the Ad Source of that ad platform in the Taku dashboard. For example:

java Copy
{
    "app_id":"2004533529842888",
    "unit_id":"VID_HD_16_9_15S_APP_INSTALL#2004533529842888_2110107055952201"
}

When the Taku SDK retrieves the backend strategy, it will convert this JSON string into a Map and pass it to loadCustomNetworkAd(Context context, Map).

• When the developer calls the Taku SDK's isAdReady API, it will call the custom Adapter's isAdReady() method.

• When the developer calls the Taku SDK's show API, it will call the custom Adapter's isAdReady() and show(Activity activity) methods.

3.2 Notes

• When adding a custom ad platform in the Taku dashboard, the Adapter class name must be configured with the full path class name (package name + class name), otherwise the Adapter class will not be created correctly when loading ads.

• Since the SDK internally creates the Adapter class through reflection, when building a release package, you must ensure that the Adapter class is not obfuscated. An example of the obfuscation rule is as follows:

java Copy
# Replace  with the developer's own Adapter class name. 
-keep class  { *;} 
-keepclassmembers public class  { 
    public *; 
}

• For any issues encountered, refer to How to Test Ads for solutions.

Previous
Custom Adapter
Next
Banner Ad
Last modified: 2026-07-08Powered by