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 to wrap_content
and everything worked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.