Initialize the Audience Network SDK for Android
Updated: May 8, 2026
Copy for LLM
When using the Audience Network SDK for Android, the
initialize() method must be called prior to any other SDK operations. In the following example, the context variable represents an Application or Activity.AudienceNetworkAds.initialize(context);
Helper Class Example for Audience Network SDK Initialization
The following example is a helper class that shows how to call the initialize method of Audience Network SDK for Android.
Once the class is defined in your app, call
AudienceNetworkInitializeHelper.initialize(context) to initialize the SDK from your Application.onCreate() or all Activity.onCreate() methods of Activity that contain ads./**
* Sample class that shows how to call initialize() method of Audience Network SDK.
*/
public class AudienceNetworkInitializeHelper
implements AudienceNetworkAds.InitListener {
/**
* It's recommended to call this method from Application.onCreate().
* Otherwise you can call it from all Activity.onCreate()
* methods for Activities that contain ads.
*
* @param context Application or Activity.
*/
static void initialize(Context context) {
if (!AudienceNetworkAds.isInitialized(context)) {
if (DEBUG) {
AdSettings.turnOnSDKDebugger(context);
}
AudienceNetworkAds
.buildInitSettings(context)
.withInitListener(new AudienceNetworkInitializeHelper())
.initialize();
}
}
@Override
public void onInitialized(AudienceNetworkAds.InitResult result) {
Log.d(AudienceNetworkAds.TAG, result.getMessage());
}
}