Ads are loading, but not showing?
Asked Answered
C

3

2

My interstitial ads are successfully loading, but when I call .show() on them, they don't show up.

I have followed these directions, and the ads load successfully, but don't show when I call mInterstitialAd.show();:

In onCreate():

 mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("My ID");

    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            requestNewInterstitial();
            beginPlayingGame();
        }
    });
        requestNewInterstitial();

requestNewInterstitial():

  private void requestNewInterstitial() {
        AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice("Phone's ID")
                .build();

        mInterstitialAd.loadAd(adRequest);
    }

HERE IS THE PROBLEM:

 public void tryAgain(View v) {
        if (mInterstitialAd.isLoaded()) {

            mInterstitialAd.show();
            Log.v(TAG, "LOADED in Game Over!");

        }
       else {
            beginPlayingGame();
        }

        beginPlayingGame();
    }

I get the log saying it is loaded in my log cat, but the ad doesn't actually show! Why is it loading, but not showing?

P.S. I think I actually got it to work once earlier, but it stopped working ever since then. What could be the problem?

Carangid answered 3/4, 2016 at 18:55 Comment(0)
C
1

It turns out that I just had to remove the extra method call after the else. For example,

public void tryAgain(View v) {
        if (mInterstitialAd.isLoaded()) {

            mInterstitialAd.show();
            Log.v(TAG, "LOADED in Game Over!");

        }
       else {
            beginPlayingGame();
        }

        beginPlayingGame();
    }

should have just been

public void tryAgain(View v) {
        if (mInterstitialAd.isLoaded()) {

            mInterstitialAd.show();
            Log.v(TAG, "LOADED in Game Over!");

        }
       else {
            beginPlayingGame();
        }
    //NOTICE THERE Is NO EXTRA METHOD CALL OF **beginPlayingGame()**
      }
Carangid answered 5/4, 2016 at 1:49 Comment(0)
M
0

Please add .addTestDevice("SEE_YOUR_LOGCAT_TO_GET_YOUR_DEVICE_ID") to your AdRequestBuilder

AdRequest adRequest = new AdRequest.Builder()
              .addTestDevice("SEE_YOUR_LOGCAT_TO_GET_YOUR_DEVICE_ID")
              .build();

Because in development step, if you made too many request on AdMob sometimes it starts to not showing ads. So on development process work with test ads. If it is work without any problem, when you publish your app on Play Store, your users also will see your ads without any problem

Meridethmeridian answered 3/4, 2016 at 19:0 Comment(3)
Thanks for your answer. I actually tried that, and it was working in the beginning, but it suddenly stopped working. Even with/without the ID...Carangid
Hmm than I don't see any reason to not working, but I suggest you to try to create another ad unit id and put it on your app and check results.Meridethmeridian
Yeah, this is really weird. I also tried with another ad unit id as well, but it is still not working...Carangid
L
0

Try this code

MobileAds.initialize(this, getString(R.string.admob_app_id));

private InterstitialAd mInterstitialAd;

mInterstitialAd = new InterstitialAd(this);

// set the ad unit ID
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));

loadInterstitialAds(mInterstitialAd);

 //Create loadInterstitialAds method
 public void loadInterstitialAds(final InterstitialAd mInterstitialAd) {
        AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                // Check the LogCat to get your test device ID
                .addTestDevice("Phone's ID")
                .build();

        // Load ads into Interstitial Ads
        mInterstitialAd.loadAd(adRequest);

        mInterstitialAd.setAdListener(new AdListener() {
            public void onAdLoaded() {
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                }
            }
        });
    }
Loney answered 14/3, 2019 at 11:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.