2.2. SDK Initialization Configuration
We recommend downloading and experiencing the Mediation Demo to gain a more intuitive understanding of the SDK's features and usage.
Initialization example code:
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
/**
* In 'multi-process + WebView scenarios', each process must use a different WebView data
* directory. Starting from Android P (9.0), Google disallows WebView instances in different
* processes from sharing the same data directory.
*
* Solution: Before calling TAdManager.init(), assign each process a unique WebView data
* directory suffix in Application.onCreate().
*
* Note: The 'Yandex' ad source is multi-process — configure this after integration.
* Example:
* // Assign a unique suffix per process
* WebView.setDataDirectorySuffix(processName);
*/
TAdManager.init(this, new TAdManager.AdConfigBuilder()
// Required — apply for your App ID from the ad operations team
.setAppId("your_app_id")
// Optional — enables ad logging (keywords: ADSDK_M, ADSDK_N); default false
.setDebug(BuildConfig.DEBUG)
// Optional — marks the current device as a test device; default false
// Effective only for Hisavana SSP, AdMob, Facebook, AppLovin, Unity, and MAX
// Configure other ad sources according to their platform documentation
.testDevice(false)
// Optional — globally mutes video-type ads; default true (muted)
.setMuteVideo(false)
// Optional — initializes Admob synchronously at SDK init time; default false
.isInitAdMob(false)
// Optional — pre-initializes the Pangle ad source with its App ID
.initPangleAdvance("your_pangle_app_id")
// Optional — disables Pangle's internal multi-process WebView file lock; default false
.closePangleWebFileLock(false)
// Optional — zip package version for the built-in fallback ad feature
// (provided by operations, type: Long)
.setInternalDefaultAdVersion(1710853164130L)
// Optional — optimizes Glide image loading for Splash/Interstitial/Reward
// (Hisavana SSP ad source only); default false
.setShouldOptimizeImageLoading(true)
// Optional — shows a toast after reward completion in new Hisavana SSP ad styles
// true: show, false: hide, default true
.setRewardedCompletionToastEnabled(true)
// Optional — fires when cloud config initialization completes (max 15 s)
// Strongly recommended: request ads only after this callback fires
.setCloudCompleteListener(new TAdManager.OnCloudCompleteListener() {
@Override
public void onCloudComplete(int code, String message) {
// Record code and message with the application logging system
if (code == 0) {
// Request ads here
}
}
})
.build());
}
}
Strongly Recommended: Record the initialization callback's code and message, and request ads only after code == 0. For a non-zero code, follow the Troubleshooting Guide to resolve initialization or cloud configuration errors first.