Initialize the SDK

After you add the AwesomeAds SDK to your project, you need to initialize it.

After adding the SDK to your project, initialize it in the Application subclass in your Android app:

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        AwesomeAds.init(this, true);
    }
}
class MyApplication : Application() {
    
    override fun onCreate() {
        super.onCreate()
        AwesomeAds.init(this, true)
    }
}

where the init method takes:

  • this - the application context.
  • a Boolean parameter indicating whether logging is enabled or not. For production environments logging should be off (false).

The SDK can also be initialized with an options dictionary. The options dictionary is used to set additional tracking information in the form of key-value pairs. This information is sent when events are fired from the SDK. For example:

public class MyApplication extends Application {
    @Override 
    public void onCreate() { 
        super.onCreate(); 
        Map<String, Object> options = new HashMap<>();
        options.put("key", "value");
        AwesomeAds.init(this, true, options);
    } 
} 
class MyApplication : Application() {
    
    override fun onCreate() {
        super.onCreate()
        AwesomeAds.init(this, true, mapOf("key", "value"))
    }
}