Libgdx - >单击后,AdMob我的横幅可见

时间:2017-06-20 06:15:05

标签: android libgdx

我在我的应用程序中配置了admob,但问题是当我开始游戏时。我只是没有看到横幅,只是当我点击它然后添加是打开,当我回到游戏我看到横幅。我不知道什么是错的。我的申请有黑色背景

这是我的代码:

adView = new AdView(this);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useAccelerometer = true;
RelativeLayout relativeLayout = new RelativeLayout(this);
View gameView = initializeForView(new SkippyFlowersGame(this), cfg);
relativeLayout.addView(gameView);
adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            Log.i(TAG, "Ad Loaded...");
        }
    });
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId("XXXXXXXXXXXXXXXXXXXXXXXXXXX");
AdRequest.Builder builder = new AdRequest.Builder();
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
relativeLayout.addView(adView, adParams);
adView.loadAd(builder.build());
setContentView(relativeLayout);

1 个答案:

答案 0 :(得分:1)

通过以这种方式覆盖pause()的方法,确保您正在调用resume()的{​​{1}},destroy()AdView方法:

Activity

此外还有问题,请看一下这个answer。这可能会有所帮助。