問題是,在540x960分辨率(我的手機)上,廣告效果不錯,但在其他解決方案中效果不佳。這是一個錯誤:「沒有足夠的空間來展示廣告」。我認爲這可能是錯誤的佈局,但我不知道是什麼。AdMob libgdx。廣告未顯示
我的MainActivity:
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
//initialize(new JumpJackieJump(this), cfg);
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
RelativeLayout layout = new RelativeLayout(this);
requestWindowFeature(Window.FEATURE_NO_TITLE); //no title is needed
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
adView = new AdView(this);
adView.setAdUnitId(ADCODE);
adView.setAdSize(AdSize.SMART_BANNER);
ad = new InterstitialAd(this);
ad.setAdUnitId(FULLADCODE);
View gameView = initializeForView(new JumpJackieJump(new RequestHandler(adView, ad), this), cfg);
AdRequest adRequest = new AdRequest.Builder().build();
AdRequest fadReq = new AdRequest.Builder().build();
adView.loadAd(adRequest);
ad.loadAd(fadReq);
layout.setPadding(0, 0, 0, 0);
layout.addView(gameView);
RelativeLayout.LayoutParams adParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
layout.addView(adView, adParams);
setContentView(layout);
if (!ad.isLoaded())
ad.loadAd(fadReq);
ad.setAdListener(new AdListener()
{
@Override
public void onAdClosed()
{
AdRequest fadReq = new AdRequest.Builder().build();
ad.loadAd(fadReq);
}
});
做的解決方案的工作? – 2014-12-01 09:19:25
是的,它的工作;)謝謝你的答案。 – metalcracker 2014-12-01 16:15:00