【问题标题】:ANDEngine ADmob AD not visibleANDEngine ADmob AD 不可见
【发布时间】:2014-02-11 19:01:09
【问题描述】:

我正在尝试在我用 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);
}

【问题讨论】:

  • logcat 说什么?

标签: android admob andengine


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多