请帮忙。插页式广告只展示一次。我希望它能更多地显示出来。
private void loadAds() {
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
interstitial = new InterstitialAd(this);
AdRequest adRequest2 = new AdRequest.Builder().build(); //
interstitial.setAdUnitId(getResources().getString(R.string.admob_interstitial));
interstitial.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
AdLoaded = true;
}
@Override
public void onAdClosed() {
super.onAdClosed();
}
@Override
public void onAdFailedToLoad(int errorCode) {
AdLoaded = true;
}
});
interstitial.loadAd(adRequest2);
}
public void displayInterstitial() {
if (adsCounter == 0) {
if (interstitial.isLoaded()) {
interstitial.show();
}
adsCounter = 0;
} else {
adsCounter += 2;
}
}
答案 0 :(得分:0)
在显示插页式广告后,您需要再次致电loadAd(adRequest)
才能加载新的插页式广告。
答案 1 :(得分:0)
使用此
重新OnAdClosed()
@Override
public void onAdClosed ()
{
AdRequest adRequest = new AdRequest.Builder()
.build();
interstitial.loadAd(adRequest);
}
答案 2 :(得分:0)
对我来说,我不得不打电话给.destroy并制作新的实例。
制作全局变量
private MoPubInterstitial interstitial;
将样板代码放在函数中:createInterstitialAd。
private void createInterstitialAd(){
// TODO: Replace this test id with your personal ad unit id
interstitial = new MoPubInterstitial(getActivity(), "<#YOUR_AD_UNIT_ID#>");
interstitial.setInterstitialAdListener(this);
interstitial.load();
}
然后在InterstitialAdListener方法中广告无法加载或加载调用后(注意: 也在onCreateView中调用 )
interstitial.destroy();
createInterstitialAd();