Interstitial ads Forndroid Studio implement step by step Code 2022

0
(0)

Interstitial ads are full-screen ads that cover the interface of their host app. Today we will tell you in this post how you can install Interstitial ads in your app through android-studio, we will tell you step by step how to install.

In very simple language, we told you how you can put Interstitial ads on your app, nothing we tell you.

Fast Step:

build.gradle:

1.

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

2.

Manifest.xml:

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

3.



private InterstitialAd mInterstitialAd;

Full code interstitial ad for Android studio:




        MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {}
        });
        AdRequest adRequest = new AdRequest.Builder().build();

        InterstitialAd.load(this,"ca-app-pub-3940256099942544/1033173712", adRequest,
                new InterstitialAdLoadCallback() {
                    @Override
                    public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
                        // The mInterstitialAd reference will be null until
                        // an ad is loaded.
                        mInterstitialAd = interstitialAd;

                    }

                    @Override
                    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                        // Handle the error
                        mInterstitialAd = null;
                    }
                });



        mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){
            @Override
            public void onAdDismissedFullScreenContent() {
                // Called when fullscreen content is dismissed.
                Log.d("TAG", "The ad was dismissed.");
            }

            @Override
            public void onAdFailedToShowFullScreenContent(AdError adError) {
                // Called when fullscreen content failed to show.
                Log.d("TAG", "The ad failed to show.");
            }

            @Override
            public void onAdShowedFullScreenContent() {
                // Called when fullscreen content is shown.
                // Make sure to set your reference to null so you don't
                // show it a second time.
                mInterstitialAd = null;
                Log.d("TAG", "The ad was shown.");
            }
        });

3.

if (mInterstitialAd != null) {
mInterstitialAd.show(VideoActivity.this);
} else {
Log.d("TAG", "The interstitial ad wasn't ready yet.");
}

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Related Posts

Top 5 Loan Companies in India

5 (1) There are many online loan providers, but we will talk about the top 5 loan companies in India. These companies include MoneyTap, LazyPay, AnyTimeLoan, and…

Vivo S12 Pro Rumors and Specs

5 (1) The Vivo S12 Pro is expected to launch in China on December 10 with a customized Dimensity 1200 chipset and a triple camera configuration. These…

Credit Card Bill Payment Cashback Offers

4.1 (11) There are many different ways to get credit-card bill payment cashback offers, so it’s important to choose the one that will work best for you….

Survey Public Wants Government Websites to Be Easier to Use

0 (0) contributors of Congress might also quickly have improved avenues with which to work on behalves in their constituents. On Thursday, President Trump signed into regulation…

How the U.S. Made Hops, Skips and Leaps in Quantum Computing in 2019

5 (3) Strategic recognition and investments throughout government and industry catalyzed huge leaps in quantum and high-overall performance supercomputing over the route of 2019. In a latest…

Government and Tech Conferences Alter Plans Due to Coronavirus

0 (0) Editor’s be aware: After March 18, Nextgov will prevent updating this list given federal guidance warning against gatherings of 10 or greater human beings. national,…

Leave a Reply

Your email address will not be published.