ANDEngine ADmob AD不可见

时间:2014-02-11 19:01:10

标签: android admob andengine

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

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

我正在制作什么问题?

感谢。

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

1 个答案:

答案 0 :(得分:2)

我在旧版本的admob sdk GoogleAdMobAdsSdk-4.1.0上遇到过类似的问题。但转移到新的(至少)4.3.1解决了这个问题。你可以试试最新的sdk,然后执行相同的功能吗?希望它有所帮助。