Configuration

This guide explains how to initialize and configure the Empower Mobile Ads SDK in your application.

SDK Initialization

Initialize the SDK as early as possible in your application lifecycle. The recommended approach is to initialize in your Application class.

Basic Initialization

// MyApplication.kt
import android.app.Application
import net.empower.mobile.ads.api.EMAManager
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
EMAManager.init(
application = this,
appAdIdentifier = "YOUR_APP_AD_IDENTIFIER"
)
}
}

Important: Replace YOUR_APP_AD_IDENTIFIER with the app identifier provided by Empower.

Advanced Initialization with Configuration

For more control over the SDK behavior, use the EMAConfiguration builder:

// MyApplication.kt
import android.app.Application
import net.empower.mobile.ads.api.EMAManager
import net.empower.mobile.ads.api.model.EMAConfiguration
import net.empower.mobile.ads.api.model.LogLevel
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val configuration = EMAConfiguration.Builder(
application = this,
appAdIdentifier = "YOUR_APP_AD_IDENTIFIER"
)
.debugMode(BuildConfig.DEBUG)
.logLevel(LogLevel.DEFAULT)
.nonPersonalizedAds(false)
.build()
EMAManager.init(configuration)
}
}

Configuration Options

OptionTypeDefaultDescription
debugModeBooleanfalseEnables verbose logging for debugging. Disable in production.
logLevelLogLevelNONEControls the verbosity of SDK logs.
nonPersonalizedAdsBooleanfalseWhen true, serves only non-personalized ads (GDPR compliance).

Log Levels

LevelDescription
ALLLogs all messages including debug information
DEFAULTLogs general information and errors
WARNINGLogs warnings and errors only
ERRORLogs errors only
NONEDisables all logging

Register Your Application Class

Ensure your custom Application class is registered in AndroidManifest.xml:

<manifest>
<application
android:name=".MyApplication"
...>
<!-- Activities and other components -->
</application>
</manifest>

Automatic Ad Queueing

All ad types (banner, interstitial, rewarded, app open) automatically queue if called before SDK initialization completes. You can safely load ads immediately after calling init():

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
EMAManager.init(this, "YOUR_APP_AD_IDENTIFIER")
// These calls are safe immediately after init()
// They will queue and execute once SDK is ready
EMAManager.loadInterstitialAd("interstitial_zone_id")
EMAManager.loadRewardedAd("rewarded_zone_id")
EMAManager.loadAppOpenAd("app_open_zone_id")
}
}

Listening for SDK Ready State (Optional)

If you need to know exactly when the SDK is ready (for analytics, UI updates, etc.), you can implement EMASdkReadyListener:

import net.empower.mobile.ads.api.EMAManager
import net.empower.mobile.ads.api.listeners.EMASdkReadyListener
class MyApplication : Application(), EMASdkReadyListener {
override fun onCreate() {
super.onCreate()
EMAManager.setSdkReadyListener(this)
EMAManager.init(this, "YOUR_APP_AD_IDENTIFIER")
}
override fun onReady() {
// SDK is initialized and ready to load ads
// Use this for analytics or UI updates
}
override fun onFailed(error: Throwable?) {
// SDK initialization failed
// Handle the error appropriately
}
}

Note: This listener is optional. Since all ad types automatically queue, you don't need to wait for onReady() before loading ads.

GDPR Compliance

For users in regions requiring GDPR compliance, enable non-personalized ads:

// Option 1: During initialization
val configuration = EMAConfiguration.Builder(this, "YOUR_APP_AD_IDENTIFIER")
.nonPersonalizedAds(true)
.build()
// Option 2: At runtime based on user consent
EMASettings.isAdsNonPersonalized = !userHasGivenConsent

Shutdown

Use shutdown() when you no longer want to show ads (e.g., user bought premium or you decide to stop displaying ads):

// Stop all ads
EMAManager.shutdown()
// Reinitialize when you want to show ads again
EMAManager.init(application, "YOUR_APP_AD_IDENTIFIER")