[英]AndEngine ads with Google Play Services
I created an application with AndEngine that is using only one View, the game itself. 我使用AndEngine创建了一个仅使用一个视图(游戏本身)的应用程序。 It extends the SimpleBaseGameActivity, but my problem occurs on all of those:
它扩展了SimpleBaseGameActivity,但是我的问题发生在所有这些方面:
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 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. 还可以查看eclipse的屏幕截图以获取详细信息。
Am I right when I assert that all of those 25 examples that I have found are deprecated due to a new version? 我断言我发现的所有25个示例都由于新版本而被弃用了,对吗?
These methods are from the "old" admob API that will be deprecated very soon. 这些方法来自“旧” admob API,该API将很快弃用。 Now admob is integrated with Google Play Game Services.
现在admob已与Google Play游戏服务集成。 So you need to remove the admob library, and use the new API: https://developers.google.com/mobile-ads-sdk/docs/?hl=es
因此,您需要删除admob库,并使用新的API: https : //developers.google.com/mobile-ads-sdk/docs/?hl=es
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.