logo

Help Center/Details/

Initialize Pangle SDK

Initialize Pangle SDK asynchronously is supported since the v3.5.0.0 SDK, please call TTAdSdk.init(final Context var0, final TTAdConfig var1, final TTAdSdk.InitCallback var2) to initializes the SDK before you send any ad requests. Init only need to be called once per app’s lifecycle, we strongly recommend to do this on app launch.

TTAdSdk.InitCallback will be informed about the result of the initialize.

If you use TextureView for video ads, please set useTextureView(true) in the Builder and add add WAKE_LOCK permission in the manifest.


    public class DemoApplication extends Application {
        @Override
        public void onCreate() {
            super.onCreate();

            TTAdSdk.init(context, buildConfig(), new TTAdSdk.InitCallback() {
                @Override
                public void success() {
                    //load pangle ads after this method is triggered.
                   
                }

                @Override
                public void fail(int code, String msg) {
                    
                }
            });
        }
        
        private TTAdConfig buildConfig() {
              return new TTAdConfig.Builder()
                    .appId("Your_App_Id")
                    .supportMultiProcess(false) 
                    .coppa(0) 
                    .build());
        }
    }

You also could check the initialization status with the method TTAdSdk.isInitSuccess()

TTAdSdk.isInitSuccess();


Before v3.5.0.0, please use synchronous method TTAdSdk.init(Context var0, TTAdConfig var1) to initialize Pangle SDK.

Warning: Ads may be preloaded by the Pangle Ads SDK or mediation partner SDKs after initialize. If you need to obtain consent from users under age 13, please ensure you do so before initializing the Pangle Ads SDK.


If you want to change the value of COPPA after initializing Pangle SDK, you can call following method, as shown below:

TTAdSdk.setCoppa(int CoppaValue);
Did the content solve your problem?