samedi 9 mai 2015

admob of google play service does not showing over surfaceview

I have an android game that draws on a surfaceView and I have admob ads on top of that using a FrameLayout. FrameLayout lay = new FrameLayout(this); this.addContentView(lay, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    AdView adView = new AdView(this, AdSize.BANNER, "xxxxxxxx");
    lay.addView(renderer, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    lay.addView(adView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    adView.setGravity(Gravity.LEFT);
    this.setContentView(lay);
    adView.loadAd(new AdRequest());

and everything is fine. I want to integrate the new google play services admob and I have changed the above code to

FrameLayout lay = new FrameLayout(this);
    this.addContentView(lay, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    adView = new AdView(this);
    adView.setAdUnitId("xxxxxxx");
    adView.setAdSize(AdSize.BANNER);
    lay.addView(adView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    this.setContentView(lay);
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);        

the admob view is not shown up. I know that it is the view that does not come up because if i add only the AdView into the frameLayour then I see the ads without any problem

Has anyone came across this problem? Has anyone any suggestion about that?

king regards

Aucun commentaire:

Enregistrer un commentaire