gpt4 book ai didi

java - 使用 Google Play 服务的 AndEngine 广告

转载 作者:行者123 更新时间:2023-12-01 12:52:25 25 4
gpt4 key购买 nike

我使用 AndEngine 创建了一个应用程序,该应用程序仅使用一个 View ,即游戏本身。它扩展了 SimpleBaseGameActivity,但我的问题发生在所有这些上:

我在网上找到的每个例子都不起作用,而且原因非常相似。下面的例子摘自

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);
}

另请查看a screenshot from eclipse了解详情。

当我断言我发现的所有 25 个示例都因新版本而被弃用时,我是对的吗?

最佳答案

这些方法来自“旧”admob API,很快就会被弃用。现在,admob 已与 Google Play 游戏服务集成。所以你需要删除admob库,并使用新的API:https://developers.google.com/mobile-ads-sdk/docs/?hl=es

关于java - 使用 Google Play 服务的 AndEngine 广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24118974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com