Skip to main content

2.2. SDK Initialization Configuration

We recommend that you download and experience the Mediation Demo to gain a more intuitive and in-depth understanding of the SDK's features and usage. Through the Demo, you can quickly get started and explore its application in real-world scenarios.

Initialization example code:

public class DemoApplication extends Application {

@Override
public void onCreate() {
super.onCreate()
/**
* 'Multi-process and WebView scenario' requires setting different data directories for WebView, reason:
* After Android P(9.0), to enhance security and avoid conflicts between WebView instances in different processes,
* Google introduced a new restriction: WebView instances in different processes are not allowed to use the same data directory.
*
* Solution:
* To avoid this issue, it is recommended to specify a unique directory for WebView instances in each process,
* in the Application's onCreate() method and before SDK initialization.
*
* Known ad source 'Yandex' is multi-process, please set according to actual situation after integration.
* Example:
* // Set unique suffix for each process
* WebView.setDataDirectorySuffix(processName);
*/

TAdManager.init(this, new TAdManager.AdConfigBuilder()
// Required, please apply on the ad platform
.setAppId("your app id")
// Optional, whether to print ad logs, default is false; if set to true, logs will be printed with keywords ADSDK_M, ADSDK_N
.setDebug(BuildConfig.DEBUG)
// Optional, whether to request test ads, default is false; if true, request test ads from ad platforms, otherwise request production ads
.testDevice(false)
// Optional, whether to globally mute video ads
.setMuteVideo(false)
// Optional, whether to perform Admob initialization at this time
.isInitAdMob(false)
// Optional, whether to perform Pangle initialization at this time
.initPangleAdvance("pangle id")
// Optional, Whether to disable the internal multi-process WebView setting in Pangle
.closePangleWebFileLock(true)
// Optional, if enabling native ad feature needs to be set, value is the version number of the zip package (provided by operations, unit: Long), used for fallback ad updates
.setInternalDefaultAdVersion(1710853164130L)
// Optional, whether to enable image loading resource competition optimization function (only effective when ad source Hisavana uses Glide image loading library and ad units are Splash, Interstitial, Reward). Enable set to true, disable set to false, default disabled
.setShouldOptimizeImageLoading(true)
// Optional. Controls whether to enable the toast prompt after reward completion (only applicable to the new interstitial and rewarded ad styles of the Hisavana ad source). true: enabled, false: disabled, default is true.
.setRewardedCompletionToastEnabled(true)
// Optional, please wait for initialization callback to complete before requesting ads to avoid ad request failures due to incomplete initialization, maximum wait time 15s
.setCloudCompleteListener(new TAdManager.OnCloudCompleteListener())
.build());
}
}

Strongly Recommended: Please wait for the initialization callback to complete before requesting ads to avoid ad request failures due to incomplete initialization.