LibGDX和Admob:我没看到广告

时间:2013-08-18 22:12:26

标签: java android admob libgdx

我尝试了一切,代码正常运行,但我看不到我的广告。在我的admob帐户上也没有请求......

这是我的代码

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  View gameView = initializeForView(new com.me.game.App(), false);
  AdView adView = createAdView();
  RelativeLayout layout = new RelativeLayout(this);
  RelativeLayout.LayoutParams adParams = 
        new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                        RelativeLayout.LayoutParams.WRAP_CONTENT);
  adParams.addRule(RelativeLayout.ALIGN_BASELINE);
  LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT,     LayoutParams.WRAP_CONTENT);
  layout.addView(adView, adParams);
  layout.addView(gameView, layoutParams);
  setContentView(layout);
  startAdvertising(adView);
}

private AdView createAdView() {
  AdView adView = new AdView(this, AdSize.SMART_BANNER,"PUBLISHER_ID");
  return adView;
}

private void startAdvertising(AdView adView) {
  AdRequest adRequest = new AdRequest();
  adRequest.addTestDevice("A0FA8C8161016266010B4E4239CD92D5"); // My Test Device
  adView.loadAd(adRequest);
}

}

2 个答案:

答案 0 :(得分:2)

您正在广告视图后添加游戏视图。另外为了更好地控制,最好这样做:

https://code.google.com/p/libgdx/wiki/AdMobInLibgdx

答案 1 :(得分:0)

您是否尝试将AdView的背景颜色设置为透明?

adView.setBackgroundColor(Color.TRANSPARENT);