I’m need to include ads into my app and I have a settings option to disable ads. so I need to load the ad in code. I copied the code from google to handle that and when I set ads:loadAdOnCreate to true, it works just fine.
But if I set it to false and add the two lines
AdView adView = (AdView)this.findViewById(R.id.ad);
adView.loadAd(new AdRequest());
The ads stop displaying. If I look at log cat, it shows that it is receiving an ad and trying to display it. However it won’t actually display on screen. Help?
No matter if I’m loading the ad in xml or in code, the following warning shows up in logcat despite the fact I’m giving the banner the whole screen.
11-16 18:53:37.128: W/Ads(19401): Not enough space to show ad! Wants: <480, 75>, Has: <456, 133>
I figured out what was wrong. I was including a fragment whose height was set to
fill_parent. I changed that setting towrap_contentand everything worked.