Android插页式广告只展示一次

时间:2016-05-28 10:26:50

标签: android admob native ads interstitial

我只能让它显示一次,当我请求另一个广告或者只是尝试再次显示相同的广告时它不起作用..无论我做什么,它只显示一次。我试过了

我有这个onCreate

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

  mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
AdRequest adRequestInterstial =  new AdRequest.Builder()
        .addTestDevice("xxxxxxxxxxxxxxxxxxx")
        .build();
mInterstitialAd.loadAd(adRequestInterstial);

然后我有召唤码

  if(mInterstitialAd.isLoaded()){
                        mInterstitialAd.show();
                       requestNewInterstitial();
                    }

requestNewInterstitial代码:

private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("xxxxxxxxxxxxxxxxxxxxxxx")
            .build();

    mInterstitialAd.loadAd(adRequest);
}

谢谢。

1 个答案:

答案 0 :(得分:0)

//listner for adClosed fixed the situation
mInterstitialAd.setAdListener(new AdListener() {
    @Override
    public void onAdClosed() {
        AdRequest adRequest =  new AdRequest.Builder()
                .addTestDevice("xxxxxxxxxxxxxxxxxx")
                .build();
        mInterstitialAd.loadAd(adRequest);
    }
});