Initialize the Audience Network SDK

Explicit initialization of the Audience Network Android SDK is required for version 5.3.0 and greater.

When using Audience Network SDK for Android version 5.3.0 and greater, the initialize() method must be called prior to any other SDK operations. In the following example, the context variable represents an Application or Activity.


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) {

                .withInitListener(new AudienceNetworkInitializeHelper())

    public void onInitialized(AudienceNetworkAds.InitResult result) {
        Log.d(AudienceNetworkAds.TAG, result.getMessage());