android - Google service Ads behaves differently than AdMob SDK while loading ads? -


I recently migrated to the Google service advertising their project AdMob SDK, although I do with a Google service ads small problem

a banner ad view activity to me, and I can dynamically adjust the buttons in the layout, that this depends on the ad load or not . When I used the AdMob SDK, but now it works fine with Google service advertising, the banner is always spaced out before the ad loads. And if the ad can not be loaded (say without network), there is an empty view, which is ugly! This is also because I'd like to adjust the layout dynamically ...

Did I miss anything while changing the code? Thanks for the help!

Here is an excerpt of Java code and layout file:

Java:

  import com.google.android gms.ads *. ... enhances public square MyActivity activity ... {Override public void onCreate (Bundle saved Instensstet) {... AdView adView = (AdView) findViewById (R.id.ad); AdRequest adRequest = new AdRequest.builder (). Build (); AdView.loadAd (adRequest); }}  

Layout XML:

  ...  

You can add a AdListener, and ads can show only a Get the ad

The code looks like this:

last ad view ad = new ad view (context); Ad.setAdUnitId (publisherId); Ad.setAdSize (AdSize.SMART_BANNER); Final AdListener Listener = New AdListener () {@Override Adored (Public) on public Zero {ad.setVisibility (see Visual.); Super.onAdLoaded (); }}; Ad.setAdListener (listener); Ad.setVisibility (View.GONE); AdParent.addView (Advertisement); Ad.loadAd (New AdRequest.Builder (.) Build ());

Since there was a problem, so that an AdMob ad generates an ANR, even when it is loading when loading. I usually pause () or delete () .

Check the visibility of the ad before calling.

Comments