Admob插页式错误

时间:2013-09-26 13:53:06

标签: android admob andengine

我想打电话给Admob插页式广告?多次在我的Android应用中。我对此事感到困惑。

interstitial = new InterstitialAd(this, "ID");
        final AdRequest adRequest = new AdRequest();
        interstitial.loadAd(adRequest);
        interstitial.setAdListener(this);

我尝试了这段代码,这适用于一次性调用。当它第二次调用时会显示错误。

帮我解决这个问题。

提前感谢。

1 个答案:

答案 0 :(得分:0)

您需要分隔插页式广告的结构,加载广告并展示广告。

public void onCreate(Bundle savedInstanceState) {
  interstitial = new InterstitialAd(this, "MY-AD-ID");
  interstitial.setAdListener(new AdListsner() {
     ..
  });
}

private void loadAd() {
  final AdRequest adRequest = new AdRequest();
  interstitial.loadAd(adRequest);
}

private void showAd() {
  if (interstitial.isLoaded()) {
    interstitial.show();
  }
}