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
- Kotlin
- Java
// MyApplication.ktimport android.app.Applicationimport net.empower.mobile.ads.api.EMAManagerclass MyApplication : Application() {override fun onCreate() {super.onCreate()EMAManager.init(application = this,appAdIdentifier = "YOUR_APP_AD_IDENTIFIER")}}
Important: Replace
YOUR_APP_AD_IDENTIFIERwith the app identifier provided by Empower.
Advanced Initialization with Configuration
For more control over the SDK behavior, use the EMAConfiguration builder:
- Kotlin
- Java
// MyApplication.ktimport android.app.Applicationimport net.empower.mobile.ads.api.EMAManagerimport net.empower.mobile.ads.api.model.EMAConfigurationimport net.empower.mobile.ads.api.model.LogLevelclass 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
| Option | Type | Default | Description |
|---|---|---|---|
debugMode | Boolean | false | Enables verbose logging for debugging. Disable in production. |
logLevel | LogLevel | NONE | Controls the verbosity of SDK logs. |
nonPersonalizedAds | Boolean | false | When true, serves only non-personalized ads (GDPR compliance). |
Log Levels
| Level | Description |
|---|---|
ALL | Logs all messages including debug information |
DEFAULT | Logs general information and errors |
WARNING | Logs warnings and errors only |
ERROR | Logs errors only |
NONE | Disables all logging |
Register Your Application Class
Ensure your custom Application class is registered in AndroidManifest.xml:
<manifest><applicationandroid: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():
- Kotlin
- Java
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 readyEMAManager.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:
- Kotlin
- Java
import net.empower.mobile.ads.api.EMAManagerimport net.empower.mobile.ads.api.listeners.EMASdkReadyListenerclass 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:
- Kotlin
- Java
// Option 1: During initializationval configuration = EMAConfiguration.Builder(this, "YOUR_APP_AD_IDENTIFIER").nonPersonalizedAds(true).build()// Option 2: At runtime based on user consentEMASettings.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):
- Kotlin
- Java
// Stop all adsEMAManager.shutdown()// Reinitialize when you want to show ads againEMAManager.init(application, "YOUR_APP_AD_IDENTIFIER")