2014-02-11 25 views
2

我試圖在我的AndEngine遊戲中顯示adMob廣告。ANDEngine ADmob AD不可見

我能夠得到我的WebRequest在LogCat中的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); 
} 
+0

logcat說什麼? – William

回答

2

我有一個老版本的admob sdk GoogleAdMobAdsSdk-4.1.0類似的問題。但轉向新的(至少)4.3.1解決了這個問題。你可以試試最新的SDK,然後執行相同的功能?希望能幫助到你。

+2

謝謝你,這對我有效 – mfq