问题
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