Admob 广告仅在首次刷新后出现 [英] Admob ads appear only after first refresh

查看:24
本文介绍了Admob 广告仅在首次刷新后出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将来自 admob 的横幅广告添加到我的游戏中,并且横幅添加仅在第一次刷新(30 秒)后出现.在前 30 秒内,它就在那里,如果您点击应该添加广告的页面底部,它会将您带到广告页面,但广告不可见.

i added banner ads from admob to my game and the banner add appears only after the first refresh (30 seconds) . And for the first 30 seconds it's there and if you click the bottom of the page where the addvertisment should be it takes you to the advertising page but the ad is not visible.

您可以在开始游戏并单击屏幕底部时亲自查看.游戏 #1

You can see for yourself when you start the game and click bottom of the screen. Game #1

还有我的另一个游戏(如果您从该游戏的菜单(如 facebook)启动意图,然后返回菜单,广告会立即出现):游戏 #2

And my other game (if you start the intent from the menu in this game ( like facebook) and then return to the menu, ads appear instantly): Game #2

有人遇到过这种情况吗?我能做些什么来解决这个问题?

Anyone had this happen ? What can i do to fix this ?

我如何初始化我的广告:

How I initialize my ads :

    @Override
protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    RelativeLayout layout = new RelativeLayout(this);

    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
    opener = new AndroidGalleryOpener(this);
     requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    View gameView = initializeForView(new Zaidimas(opener), config);
    AdView adView = new AdView(this);
    adView.setAdUnitId("xxxxx my secret number xxxxxxxx");
    adView.setAdSize(AdSize.BANNER);
    adView.loadAd(new AdRequest.Builder()
    .build());
    layout.addView(gameView);
    RelativeLayout.LayoutParams adParams = 
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
        layout.addView(adView, adParams);
        setContentView(layout);
//initialize(new Zaidimas(opener), config);

}

推荐答案

很难说你的情况会发生什么,但我怀疑你的带有 admob 横幅的 libgdx 屏幕可能会在广告加载完成之前出现.您可以尝试添加一个 AdListener,它会在广告加载完成后强制广告视图自行绘制.比如:

It is hard to say what happens in your case, but I have a suspect that your libgdx screen with the admob banner might show up before the ad finished loading. You can try adding an AdListener that forces the ad-view to draw itself once the ad finished loading. Something like:

    adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            System.out.println("ad banner finished loading!");
            adView.setVisibility(View.GONE);
            adView.setVisibility(View.VISIBLE);
        }        
    });

代码看起来有点奇怪,但更改可见性确实应该确保您的 adView 再次被绘制;-)

The code looks a bit odd, but changing visibility should really make sure that your adView gets drawn again ;-)

这篇关于Admob 广告仅在首次刷新后出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆