Today, I will show you how to show interstitial ad in your android studio app. There are several steps so kindly follow these steps.

Steps

Step 1: Add dependency in build.gradule file.

Step 2: Add meta data in android manifest file.

Step 3: Allow Internet Permission in android manifest file.

Step 4: Add all imports in java class.

Just follow me.

Step 1:

Admob Banner Ad Dependency

implementation 'com.google.android.gms:play-services-ads:19.2.0'

Step 2:

Metadata of Admob Ads

<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>

Step 3:

Imports Of Java Code

import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.initialization.InitializationStatus; 
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;

Step 4:

Java Code

private InterstitialAd mInterstitialAd;
MobileAds.initialize(this,
            "ca-app-pub-3940256099942544~3347511713");
        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
        mInterstitialAd.loadAd(new AdRequest.Builder().build());
if (mInterstitialAd.isLoaded()) {
            mInterstitialAd.show();
        } else {
            Log.d("TAG", "The interstitial wasn't loaded yet.");
        }

Leave a Reply

Your email address will not be published. Required fields are marked *