gpt4 book ai didi

android - ANDEngine ADmob 广告不可见

转载 作者:行者123 更新时间:2023-11-29 00:23:06 26 4
gpt4 key购买 nike

我正尝试在我用 AndEngine 制作的游戏中展示 adMob 广告。

我能够在 LogCat 中针对我的 WebRequest 获取 WebViewResponse,此外,当我删除网络权限时,我收到一个带有网络要求错误的黑框。但是当我添加网络要求时,收到了网络响应,但没有成功显示它。

我正在做的可能是什么问题?

谢谢。

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

adView = new AdView(this, AdSize.BANNER, “xxxxxxxxx”);

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

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;
Log.v("AD", "Adview height : " + height);
Log.v("AD", "Adview size {x:" + adView.getWidth() + ", y: " + adView.getHeight()+ "}");
adView.setAlpha(255);

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

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

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

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

this.setContentView(frameLayout, frameLayoutLayoutParams);
}

最佳答案

我在使用旧版 admob sdk GoogleAdMobAdsSdk-4.1.0 时遇到了类似的问题。但是移动到一个新的(至少)4.3.1 解决了这个问题。你能试试最新的sdk然后执行同样的功能吗?希望对您有所帮助。

关于android - ANDEngine ADmob 广告不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21710734/

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