Admob Interstitial Ads Ads Android Studio

What is Google Admob ? How to generate Ads for Android apps ! How to monetize your android application using AdMob. AdMob is a mobile ad network from google. In this video i will show you how to place AdMob simple banner ad in your android application.






Step 1


Step 2




Step 3


Step 4


COPE CODE

    InterstitialAd mInterstitialAd;
    private InterstitialAd interstitial;


Step 5





COPE ANY ONE CODE

    <string name="admob_interstitial_id1">ca-app-pub-3940256099942544/1033173712</string>

    <string name="admob_interstitial_id2">ca-app-pub-3940256099942544/1033173712</string>

    <string name="admob_interstitial_id3">ca-app-pub-3940256099942544/1033173712</string>

MainActivity.java


COPE ANY ONE CODE

id1

        AdRequest AdRequest = new AdRequest.Builder().build();

        // Prepare the Interstitial Ad
        interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
        interstitial.setAdUnitId(getString(R.string.admob_interstitial_id1));

        interstitial.loadAd(AdRequest);
// Prepare an Interstitial Ad Listener
        interstitial.setAdListener(new AdListener() {
            public void onAdLoaded() {
// Call displayInterstitial() function
                displayInterstitial();
            }
        });
id2

        AdRequest AdRequest = new AdRequest.Builder().build();

        // Prepare the Interstitial Ad
        interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
        interstitial.setAdUnitId(getString(R.string.admob_interstitial_id2));

        interstitial.loadAd(AdRequest);
// Prepare an Interstitial Ad Listener
        interstitial.setAdListener(new AdListener() {
            public void onAdLoaded() {
// Call displayInterstitial() function
                displayInterstitial();
            }
        });
id3

        AdRequest AdRequest = new AdRequest.Builder().build();

        // Prepare the Interstitial Ad
        interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
        interstitial.setAdUnitId(getString(R.string.admob_interstitial_id3));

        interstitial.loadAd(AdRequest);
// Prepare an Interstitial Ad Listener
        interstitial.setAdListener(new AdListener() {
            public void onAdLoaded() {
// Call displayInterstitial() function
                displayInterstitial();
            }
        });
Next Step
        }
    }
    public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
        if (interstitial.isLoaded()) {
            interstitial.show();
        }
    }

}

Post a Comment

0 Comments