Display splash ad on Android

A splash ad refers to an advertisement that is displayed along with the app's logo for a short period of about 1 second when the app is first launched. Implement the Adrop SDK's splash ad screen to be the first screen displayed when the app starts, seamlessly exposing the ad before transitioning to the app's main screen. The size of the splash ad is 360dp x 270dp.


Step 1. Add resources

Replace your init activity, unit id

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="adrop_splash_ad_next_activity" 
    translatable="false">{your_init_activity}
    </string> <!-- com.company.app.MainActivity -->
    <string name="adrop_splash_ad_unit_id" 
    translatable="false">{your_splash_unit_id}
    </string> <!-- PUBLIC_TEST_UNIT_ID_SPLASH for test -->
    <integer name="adrop_splash_ad_max_timeout">1000
    </integer> <!-- (optional) default 1s -->
</resources>

- values/theme.xml

Replace parent to your application theme

<style 
    name="Theme.App.SplashTheme"
    parent="Theme.AppCompat.NoActionBar"/>

- values-v31/theme.xml

  1. Add your logo image to drawable and replace windowSplashScreenAnimatedIcon.We recommend a logo image size of 288dp x 288dp including the background, with a central logo of 128dp x 128dp

  2. Replace windowSplashScreenBackground to your splash background color

<style name="Theme.App.SplashTheme" parent="Theme.SplashScreen"> 
    <item name="windowSplashScreenAnimatedIcon">@drawable/your_logo</item>
    <item name="windowSplashScreenBackground">#ffffff</item>
    <item name="windowSplashScreenAnimationDuration">200</item>
    <item name="postSplashScreenTheme">@style/Theme.App.SplashTheme.TranslucentStatus</item>
</style>

<style name="Theme.App.SplashTheme.TranslucentStatus" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowTranslucentStatus">true</item>
</style>

Step 2. Update Androidmanifest.xml

<application>
	...
	<activity
	    android:name="io.adrop.ads.splash.AdropSplashAdActivity"
	    android:exported="true"
	    android:theme="@style/Theme.App.SplashTheme"
            tools:replace="android:theme">
	    <intent-filter>
	        <action android:name="android.intent.action.MAIN"/>
	        <category android:name="android.intent.category.LAUNCHER"/>
	    </intent-filter>
	</activity>
	...
</application>

Step 3. Add layout/activity_adrop_splash_ad.xml

  1. Replace your logo path and background color.

  2. Do not remove adrop_splash_ad_image ImageView for splash ad

(Optional) Advanced

  1. Control splash ad in callback function (remote config, etc.)

class YourApp: Application {
    // Before splash activity start
    val splashAd = AdropSplashAd(application) {
        return remoteConfig.getValue("").asBoolean()
    }
    splashAd.splashAdListener = object : AdropSplashAdListener {
        override fun onAdReceived(ad: AdropSplashAd) {
            Log.d("Adrop", "splash ad received ${ad.unitId}")
        }

        override fun onAdFailedToReceive(ad: AdropSplashAd, errorCode: AdropErrorCode) {
            Log.d("Adrop", "splash ad failed to receive ${ad.unitId}, $errorCode")
        }

        override fun onAdImpression(ad: AdropSplashAd) {
            Log.d("Adrop", "splash ad onAdImpression ${ad.unitId}")
        }
    }
    ...
}

...
// When you want to stop splash before finishing
splashAd.close()
  1. Stop splash and go to init activity

// When you want to stop splash before finishing
splashAd.close()

Last updated