0

I created an application with AndEngine that is using only one View, the game itself. It extends the SimpleBaseGameActivity, but my problem occurs on all of those:

Every example that I have found on the internet does not work, and the reasons are very similar. The example below is taken from

http://www.andengine.org/forums/tutorials/admob-xml-layout-example-t3338.html#p15852

@Override
protected void onSetContentView() {


    final FrameLayout frameLayout = new FrameLayout(this);
    final FrameLayout.LayoutParams frameLayoutLayoutParams =
            new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
                                         FrameLayout.LayoutParams.FILL_PARENT);

    final AdView adView = new AdView(this, AdSize.BANNER, "xxxxxxxxxxxx");

    adView.refreshDrawableState();
    adView.setVisibility(AdView.VISIBLE);
    final FrameLayout.LayoutParams adViewLayoutParams =
            new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
                                         FrameLayout.LayoutParams.WRAP_CONTENT,
                                         Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
    // getHeight returns 0
    // http://groups.google.com/group/admob-pu ... a874df3472
    int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50,
            getResources ().getDisplayMetrics ());
    // top of AD is at middle of the screen
    adViewLayoutParams.topMargin = height/2;

    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
    adView.loadAd(adRequest);

    this.mRenderSurfaceView = new RenderSurfaceView(this);
    mRenderSurfaceView.setRenderer(mEngine);

    final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams =
            new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());

    frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
    frameLayout.addView(adView, adViewLayoutParams);

    this.setContentView(frameLayout, frameLayoutLayoutParams);
}

Also have a look at a screenshot from eclipse for details.

Am I right when I assert that all of those 25 examples that I have found are deprecated due to a new version?

nurealam11
  • 537
  • 4
  • 16
Ercksen
  • 668
  • 9
  • 23

1 Answers1

1

These methods are from the "old" admob API that will be deprecated very soon. Now admob is integrated with Google Play Game Services. So you need to remove the admob library, and use the new API: https://developers.google.com/mobile-ads-sdk/docs/?hl=es

Sergio Viudes
  • 2,714
  • 5
  • 26
  • 44