AdMob interstitial ad only shown once

[亡魂溺海] 提交于 2019-12-23 08:34:34

问题


LogCat shows the error message "Tried to launch a new AdActivity with a different ad manager", when the ad should get opend for the second or third time within one session. I am starting the interstitial ad through an intent in the on resume method of my apps main screen:

@Override
public void onResume() {
    super.onResume();

    if(this.getIntent().hasExtra("show_ad")) {
        if(this.getIntent().getExtras().getBoolean("show_ad")) {
            showInterstitialAd();
        }
    }
}

public void showInterstitialAd() {
    mInterstitialAd = new InterstitialAd(this, "ca-app-pub-123456789");
    AdRequest adRequest = new AdRequest();
    mInterstitialAd.loadAd(adRequest);
    mInterstitialAd.setAdListener(this);
}

What can I do to avoid this? What is the meaning of this error message?


回答1:


Are you checking that the first ad is already closed? I had a similar issue, not being able to load admob's interstitial after the first time. I solved it by adding an adListner to the ad

// Set an AdListener.
interstitial.setAdListener(new AdListener() {
    @Override
    public void onAdClosed() {
      AdRequest adRequest = new AdRequest.Builder().addTestDevice(AD_UNIT_ID).build();
      interstitial.loadAd(adRequest);
    }
});


来源:https://stackoverflow.com/questions/18635138/admob-interstitial-ad-only-shown-once

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!