4

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

}
user3802649
  • 379
  • 2
  • 13

2 Answers2

6

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

donfuxx
  • 11,277
  • 6
  • 44
  • 76
0

If you're using a Relative Layout be sure to include the position of the view relative to other layout objects. I was having the same issue until I placed android:layout_below="@+id/adView" on the object directly below my adView object. You could probably just as well place android:layout_above="@+id/someView" on the adView object itself.

CoDeSigns
  • 141
  • 1
  • 2