Admob for Android Andengine Game

时间:2012-05-12 13:03:04

标签: java android admob andengine

我通过andengine创建了一个安卓游戏。我想在游戏中添加Admob广告。我使用了下面的代码。我得到了一个错误,在图片中。 http://s16.postimage.org/rz6fbr2l1/Untitled.png

 <activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation"/>

但我在上面添加了清单。那么问题是什么?

 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, "PUBLISHER_ID");

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


     AdRequest adRequest = new AdRequest();
     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);
 }

0 个答案:

没有答案