AdMob的广告后,才第一次刷新出现 [英] Admob ads appear only after first refresh

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

问题描述

我添加横幅广告AdMob提供的,以我的比赛,横幅只添加第一个刷新(30秒)后出现。而对于前30秒它的存在,如果你点击页面底部的地方addvertisment应该是它把你的广告页面,但该广告是不可见的。

您可以看到自己,当你开始游戏,点击屏幕下方。 游戏#1

和我的另一场比赛(如果你从开始菜单中的意图在这场比赛中(如Facebook),然后返回到菜单,广告就会立即显示出来): 游戏#2

没有人有这种情况发生?我能做些什么来解决这个问题?

我如何初始化我的广告:

  @覆盖
保护无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    RelativeLayout的布局=新RelativeLayout的(这一点);

    AndroidApplicationConfiguration配置=新AndroidApplicationConfiguration();
    揭幕战=新AndroidGalleryOpener(本);
     requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow()。setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        。getWindow()clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    查看gameView = initializeForView(新Zaidimas(揭幕战),配置);
    AD浏览报AD浏览报=新的AD浏览报(本);
    adView.setAdUnitId(XXXXX我的秘密号码XXXXXXXX);
    adView.setAdSize(AdSize.BANNER);
    adView.loadAd(新AdRequest.Builder()
    。建立());
    layout.addView(gameView);
    RelativeLayout.LayoutParams adParams =
            新RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
        layout.addView(AD浏览报,adParams);
        的setContentView(布局);
//初始化(新Zaidimas(揭幕战),配置);

}
 

解决方案

这是很难说的,你的情况会发生什么,但我有一个与AdMob的横幅您libgdx屏幕可能会出现前的广告加载完毕嫌疑人。你可以尝试添加强制广告视图绘制自己一旦广告加载完成的AdListener。是这样的:

  adView.setAdListener(新AdListener(){
        @覆盖
        公共无效onAdLoaded(){
            的System.out.println(广告横幅加载完成!);
            adView.setVisibility(View.GONE);
            adView.setVisibility(View.VISIBLE);
        }
    });
 

在code看上去有些奇怪,但改变的知名度要真正确保你的AD浏览报被重画; - )

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.

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

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);

}

解决方案

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);
        }        
    });

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

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

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