AdMob Interstitial Ad Implementation in Android Studio (Kotlin)

Google AdMob is one of the best monetization platforms for Android developers. Among all available ad formats, Interstitial Ads provide high-earning potential because they cover the full screen and appear at logical breaks in the app flow — such as before loading a new screen or after completing a task.

image by: openreplay

In this post, you will learn how to integrate AdMob Interstitial Ads in Android Studio using Kotlin, step by step. This guide works for 2025, uses the latest SDK guidelines, and includes complete working code.


What is an Interstitial Ad?

An interstitial ad is a full-screen ad that appears at natural transition points in your app, such as:

  • Between activities

  • After a button click

  • Before loading content

  • After completing a game level

They offer higher CPM and impressions compared to banner ads.


Step 1: Add AdMob to Your App

1. Add Google Mobile Ads SDK

Open your project-level build.gradle and add:

buildscript {
dependencies {
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.2'
}
}

Now in app-level build.gradle:

dependencies {
implementation("com.google.android.gms:play-services-ads:23.4.0")
}

Sync the project.


Step 2: Add App ID in AndroidManifest.xml

Add YOUR APP ID inside <application> tag:

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/admob_app_id" />

Step 3: Add Test Ad Unit ID

Use AdMob test ID (Recommended during development):

<!-- AdMob Test IDs -->
<string name="admob_app_id">ca-app-pub-3940256099942544~3347511713</string>
<string name="admob_banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>
<string name="admob_native_ad_unit_id">ca-app-pub-3940256099942544/2247696110</string>
<string name="admob_interstitial_ad_unit_id">ca-app-pub-3940256099942544/1033173712</string>
<string name="admob_rewarded_ad_unit_id">ca-app-pub-3940256099942544/5224354917</string>
<string name="admob_app_open_ad_unit_id">ca-app-pub-3940256099942544/9257395921</string>

Step 4: Load Interstitial Ad in Kotlin

Create a variable(Top of onCreate/onViewCreated):

private var interstitialAd: InterstitialAd? = null

Load the Ad

private fun loadInterstitial() {
val adRequest = AdRequest.Builder().build()

InterstitialAd.load(
requireContext(),
getString(R.string.admob_interstitial_ad_unit_id),
adRequest,
object : InterstitialAdLoadCallback() {

override fun onAdLoaded(ad: InterstitialAd) {
interstitialAd = ad
}

override fun onAdFailedToLoad(error: LoadAdError) {
interstitialAd = null
}
}
)
}

Call it in to onCreate() or onViewCreated()

load the ad:-
loadInterstitial()

📌 Step 6: Add Callback Events

To handle ad close, dismiss, fail, impression etc.:

private fun showInterstitialOrRun(action: () -> Unit) {
val ad = interstitialAd
if (ad != null) {
ad.fullScreenContentCallback = object : FullScreenContentCallback() {

override fun onAdDismissedFullScreenContent() {
interstitialAd = null
loadInterstitial() // reload for next time
action() // run your function
}

override fun onAdFailedToShowFullScreenContent(error: AdError) {
interstitialAd = null
action()
}
}

ad.show(requireActivity())

} else {
action() // fallback directly
}
}

Step 5: Show the Interstitial Ad

Call this function when user performs an action (e.g., button click):

binding.actionButton.setOnClickListener {
showInterstitialOrRun {
ActionFunction() // After ad action
}
}

Best Practices for Interstitial Ads

✔ Show only at natural app breaks
✔ Do not spam the user
✔ Do not mix too many ads
✔ Always preload the next ad
✔ Use test ads during development
✔ Comply with Google AdMob policies


Conclusion

You have successfully integrated AdMob Interstitial Ads in Android Studio using Kotlin.
This is the recommended modern way, fully compatible with the latest Google Play Services updates.

No comments:

Post a Comment