1

我通过andengine创建了一个android游戏。我想将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);
 }
4

0 回答 0