RelativeLayout layout = new RelativeLayout(this);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
View gameView = initializeForView(new MainGame(), config);
layout.addView(gameView);
adView = new AdView(this);
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
System.out.println("LOAD");
}
});
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId("ca-app-xxx-xxxxxxxxxx/xxxxxxxxxx");
AdRequest.Builder builder = new AdRequest.Builder();
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT
);
layout.addView(adView, adParams);
adView.loadAd(builder.build());
setContentView(layout);
Nothing is shown, no ad, why,
I added also in build.gradle (Project:projectN)
compile "com.google.android.gms:play-services-ads:$admobVersion"
Using ubuntu 16.04, android-studio
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…