本文介绍了AdMob非页内广告仅显示一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
LogCat会显示错误消息试图使用其他广告管理器启动新的AdActivity。我正在通过应用主屏幕上的on resume方法启动插页式广告:
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?
推荐答案
您是否正在检查第一个广告是否已经关闭?我遇到了类似的问题,第一次无法加载admob的插页式广告。我通过在广告中添加adListner来解决它
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);
}
});
这篇关于AdMob非页内广告仅显示一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!