Google Play Service Ads (AdMob) shows blank box until ready

3,010 views
Skip to first unread message

velec...@gmail.com

unread,
Mar 3, 2014, 4:21:00 AM3/3/14
to google-adm...@googlegroups.com

I use GPS to provide ads in my application, but there are blank box until ad is loaded and also when user doesn't have access to te Internet and it's look awful. This is i think changed behaviour in GPS SDK in migration from dedicated AdMob SDK (which is deprecated).

I tried out set listeners for onAdLoaded, which set visibility to visible after load from gone i set after create, but there is a serious problem. This is doesn't show a blank box on application start and show ad after her load. However when there are not access to the Internet, onAdLoaded don't fired anytime because of hidden Ad! Also return these logs:
Ad is not visible. Not refreshing ad.
Scheduling ad refresh 60000 milliseconds from now.

In this situation, user never sees the ad... How can I prevent GPS Ads doing this?
There is my code placed in main activity:

 adView = new AdView(this); adView.setAdListener(new AdListener() { @Override public void onAdLoaded() { adView.setVisibility(View.VISIBLE); super.onAdLoaded(); } }); adView.setVisibility(View.GONE); adView.setAdUnitId("xxx"); adView.setAdSize(AdSize.SMART_BANNER); layout = super.root; layout.addView(adView); adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest);

Amy Quispe (AdMob SDK Team)

unread,
Mar 4, 2014, 7:42:21 PM3/4/14
to google-adm...@googlegroups.com
Hi there,

I'm sorry - I don't understand the problem. It sounds like you have things figured out. In the event that the user isn't connected to the internet, you aren't displaying the view, correct? If you do want something to show up in that space, you could also try implementing some sort of Custom Event.

Hope this helps.

Amy Quispe

velec...@gmail.com

unread,
Mar 7, 2014, 3:50:06 AM3/7/14
to google-adm...@googlegroups.com
No, you are completely wrong. I hide AdView after application start and show them when ad is loaded. But if ad doesn't load for first, then won't load anytime until AdView is hidden, because "Ad is not visible. Not refreshing ad."? Is it hard to understand? Why GPS Ads showing Blank ad? AdMod SDK do not this.

Dne středa, 5. března 2014 1:42:21 UTC+1 Amy Quispe (AdMob SDK Team) napsal(a):

Kunal Verma

unread,
Mar 7, 2014, 4:09:10 AM3/7/14
to Google AdMob Ads Developers
Actually Amy is completely right. You got the things right. But the difference comes due to your understanding. With this new way of having SDK using GPS- the adView space won't remain hidden instead it takes place even if the ad is not loaded. 
It was not their before.
This has been added in the new SDK ( with GPS).
I think this has been added as most developers had the issue of adView remaining hidden before- just my Point my view for this new way.
So as it is suggested to you above, you need to use Custom events to show something else instead of this.

Best,
Kunal


--

---
You received this message because you are subscribed to the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

velec...@gmail.com

unread,
Mar 7, 2014, 8:56:02 AM3/7/14
to google-adm...@googlegroups.com
For example?

Dne pátek, 7. března 2014 10:09:10 UTC+1 Kunal Verma napsal(a):
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

Amy Quispe (AdMob SDK Team)

unread,
Mar 10, 2014, 9:04:26 PM3/10/14
to google-adm...@googlegroups.com
You can read more about Custom Events here.

Amy Quispe

velec...@gmail.com

unread,
Mar 20, 2014, 12:26:58 PM3/20/14
to google-adm...@googlegroups.com
So, there are buggy behaviout in GPS Ads and your reason is do it on your own? Why to do it easy (and fix this situation), when it can be done hardly...

Dne úterý, 11. března 2014 2:04:26 UTC+1 Amy Quispe (AdMob SDK Team) napsal(a):

Dan Dragut

unread,
Apr 1, 2014, 7:21:43 AM4/1/14
to google-adm...@googlegroups.com
I noticed this change myself the other day when trying Google Play Services Ads, that the AdView takes the layout space anyways regardless of whether it actually holds an and and that's not the case with legacy 6.4.1.

Velec, have you tried the other way around, implementing AdListener.onAdFailedToLoad() and use that to hide the AdView when it fails to load an ad (no network, no inventory etc), instead of hiding it first and showing it when you get the ad (which as you found doesn't work as the AdView checks it's visibility to prevent false impresions).

velec...@gmail.com

unread,
Apr 7, 2014, 12:33:17 PM4/7/14
to google-adm...@googlegroups.com
A tried it, but behaviour is the same: Ad is not visible. Not refreshing...

However, thank you for the tip.

This is obvious bug, but Google developers are too arogant to repair their bugs in their always buggy software.

There's my code:
        adView = new AdView(this);
            adView
.setAdListener(new AdListener() {
               
@Override
                 
public void onAdLoaded() {
                      adView
.setVisibility(View.VISIBLE);

                     
//Toast.makeText(getContext(), "Nahráno", Toast.LENGTH_LONG).show();
                 
}
                 
public void onAdFailedToLoad(int errorCode) {
                      adView
.setVisibility(View.GONE); // aby tam nebyl vidět černý čtverec, když se nepodaří načíst reklamu
                     
//Toast.makeText(getContext(), "Blbě", Toast.LENGTH_LONG).show();
                 
}
           
});
           
//adView.setVisibility(View.GONE);
            adView
.setAdUnitId("xxx");
            adView
.setAdSize(AdSize.SMART_BANNER);
           
// Lookup your LinearLayout assuming it's been given
           
// the attribute android:id="@+id/mainLayout".
            layout
= super.root;
           
// Add the adView to it.
            layout
.addView(adView);
           
// Initiate a generic request.
            adRequest
= new AdRequest.Builder().build();
           
// Load the adView with the ad request.
            adView
.loadAd(adRequest);


Dan Dragut

unread,
Apr 16, 2014, 5:39:10 PM4/16/14
to google-adm...@googlegroups.com
I don't know, I just don't feel that strong about this issue as you do, so I won't go into the debate... - what I might have for you though is a solution. Basically the solution is to wrap the AdView into a layout that is initially GONE and then on onAdLoaded() you make it visible. This way the AdView won't complain that is not visible and stop loading, it will take its space inside of the hidden container and then you practically show both on success. Here's some code, tested it in the sample project - you could define this through XML or create it through code, I'll just go for the XML version:

...
   
<FrameLayout
        android
:layout_width="match_parent"
        android
:layout_height="wrap_content"
        android
:layout_alignParentBottom="true"
        android:visibility="gone">
   
       
<com.google.android.gms.ads.AdView
            android
:id="@+id/adView"
            android
:layout_width="match_parent"
            android
:layout_height="wrap_content"
            ads
:adSize="BANNER"
            ads
:adUnitId="@string/ad_unit_id"/>
   
   
</FrameLayout>

    mAdView = (AdView) findViewById(R.id.adView);
    mAdView
.setAdListener(new AdListener() {
       
/*
         * (non-Javadoc)
         * @see com.google.android.gms.ads.AdListener#onAdLoaded()
         */

       
@Override
       
public void onAdLoaded() {
           
FrameLayout adViewContainer = (FrameLayout) mAdView.getParent();
            adViewContainer
.setVisibility (View.VISIBLE);
            adViewContainer
.startAnimation(AnimationUtils.makeInChildBottomAnimation(mAdView.getContext()));
       
}
   
});
    mAdView
.loadAd(new AdRequest.Builder().build());


Jan Velecký

unread,
Apr 17, 2014, 8:43:53 AM4/17/14
to google-adm...@googlegroups.com
I transfered your XML into code solution, but this doesn't solve anything or I did somewhere mistake. You are wright, that after Ad is loaded, everything will show, but it must be loaded for first. If connection isn't available during first loading, second and every next loading will fail with message "Ad is not visible. Not refreshing Ad." as usually... So it is same behaviour as in the previous two codes.

Here's my edited code:

            AdContainer = new FrameLayout(this);
           
AdContainer.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
           
AdContainer.setVisibility(View.GONE);
            layout
= super.root;
            layout
.addView(AdContainer);

            adView
= new AdView(this);
            adView
.setAdListener(new AdListener() {
               
@Override
                     
public void onAdLoaded() {

                       
AdContainer.setVisibility(View.VISIBLE);

                 
}
           
});
           
//adView.setVisibility(View.GONE);
            adView
.setAdUnitId("xxx");
            adView
.setAdSize(AdSize.SMART_BANNER);
           
// Lookup your LinearLayout assuming it's been given
           
// the attribute android:id="@+id/mainLayout".

           
// Add the adView to it.

           
AdContainer.addView(adView);

Dan Dragut

unread,
Apr 19, 2014, 8:55:13 AM4/19/14
to google-adm...@googlegroups.com
I see what you mean, Jan. Ok, how about this - since the concept works fine the first time, on failure we remove and destroy the old AdView and create a new one in the same container and we schedule it ourselves. This way is the same "first time" scenario can work over and over until it succeeds and its own refresh logic takes over. Yes, it's a bit more code, so I would start a new class, call it whatever you want, helper, handler etc.

    @Override
   
protected void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
        setContentView
(R.layout.activity_banner_code_ad_listener);

       
// AdView helper...
        mAdViewHelper
= new AdViewHelper(this, (RelativeLayout) findViewById(R.id.mainLayout));
        mAdViewHelper
.refresh();
   
}

   
@Override
   
protected void onPause() {
        mAdViewHelper
.pause();
       
super.onPause();
   
}

   
@Override
   
protected void onResume() {
       
super.onResume();
        mAdViewHelper
.resume();
   
}

   
@Override
   
protected void onDestroy() {
        mAdViewHelper
.destroy();
       
super.onDestroy();
   
}


public class AdViewHelper {
   
/**
     * Constants
     */

   
private final static String TAG = "AdViewHelper";
   
   
/**
     * Members
     */

   
private Context    mContext;
   
private Handler    mHandler;
   
private ViewGroup  mAdViewContainer;
   
private AdView     mAdView;
   
private AdListener mAdViewListener;
   
   
/**
     * Members
     */

   
public AdViewHelper(Context pContext, ViewGroup pViewGroup) {
       
// Init
        mContext        
= pContext;
        mHandler        
= new Handler();
       
       
// AdViewContainer...
        mAdViewContainer
= new FrameLayout(mContext);
        mAdViewContainer
.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
        mAdViewContainer
.setVisibility(View.GONE);
        pViewGroup
.addView(mAdViewContainer);
       
       
// AdViewListener...
        mAdViewListener
= new AdListener() {

           
/*
             * (non-Javadoc)
             * @see com.google.android.gms.ads.AdListener#onAdLoaded()
             */

           
@Override
           
public void onAdLoaded() {

               
// Show ad...
                mAdViewContainer
.setVisibility(View.VISIBLE);
           
}
           
/*
             * (non-Javadoc)
             * @see com.google.android.gms.ads.AdListener#onAdFailedToLoad(int)
             */

           
@Override
           
public void onAdFailedToLoad(int errorCode) {
               
// Fail...
               
Log.e(TAG, String.format("onAdFailedToLoad(%s)", errorCode));

               
// Refresh it ourselves...
                mHandler
.removeCallbacks(null);
                mHandler
.postDelayed(new Runnable() {
                   
@Override
                   
public void run() {
                        refresh
();
                   
}
               
}, 60000);
           
}
       
};
   
}

   
/**
     * Refresh ad.
     */

   
public final void refresh() {
       
// Destroy old instance...
        destroy
();
       
       
// Create new instance...
        mAdView
= new AdView(mContext);
        mAdView
.setAdUnitId(mContext.getResources().getString(R.string.ad_unit_id));
        mAdView
.setAdSize(AdSize.BANNER);
        mAdView
.setAdListener(mAdViewListener);
       
       
// Add to container...
        mAdViewContainer
.addView(mAdView);
       
       
// Request new ad...
        mAdView
.loadAd(new AdRequest.Builder().build());
   
}
   
   
/**
     * Pause ad.
     */

   
public final void pause() {
        mAdView
.pause();
   
}
   
   
/**
     * Resume ad.
     */

   
public final void resume() {
        mAdView
.resume();
   
}

   
/**
     * Destroy ad.
     */

   
public void destroy() {
        mHandler
.removeCallbacks(null);
       
if (mAdView != null) {
            mAdView
.destroy();
       
}
        mAdViewContainer
.removeAllViews();
   
}



Jan Velecký

unread,
Apr 19, 2014, 2:14:00 PM4/19/14
to google-adm...@googlegroups.com
Exciting. Why we need patching Google library...?

Your solution is nice, but there are detail with pausing, which I must probably solve. When application is paused and handler running, AdMob is not paused in fact, because handler continue and will create new adView, which will not be paused...

Dan Dragut

unread,
Apr 19, 2014, 2:50:08 PM4/19/14
to google-adm...@googlegroups.com
Hey Jan,

Yes, there are some more details to iron out, but at least you have a working concept to start with.

Well, I wasn't very happy either with some of the changes and removals compared to the old one - e.g. removal of ads:loadAdOnCreate and ads:shortTimeout attributes, plus some bits discussed on a separate discussion here involving background threads not paused - which gives the impression that the code wasn't just a lift & shift job, the team may have used the opportunity to change certain things like this one, but just as well the library might get them back if others request them again.

My impression is that this behaviour was probably requested by other developers so the space is already measured and taken so you don't have to do it yourself, if you want to avoid your contents to be pushed up or down when the ad loads 2-3 seconds later - it might be easy for 320x50 banners but some use the new SMART_BANNER and that may has  different sizes depending on the resolution. In theory, you could use this to your advantage, and instead of seeing the blank space you could use the FrameLayout to parent a "Loading..." or "Advertisement" logo and then onAdLoaded() to flip them so you see the ad in front, I don't know... they probably thought it would be easier to hide things or move them behind other things than to measure stuff you don't know.

Well, best of luck with your application, Jan!

Jan Velecký

unread,
Apr 19, 2014, 4:04:48 PM4/19/14
to google-adm...@googlegroups.com
You are wright, still it need too much own code to achieve earlier behaviour. But now, blank box is hidden, and ad is showed, so I'm happy with it. :-)

Thank you for your assistance, Dan.

Jan Velecký

unread,
Apr 20, 2014, 5:51:26 AM4/20/14
to google-adm...@googlegroups.com
A small note, is need to use handler.removeCallbacksAndMessages(null) instead of handler.removeCallbacks(null) to correct remove all handlers in this case.

Baris Efe

unread,
Jun 9, 2014, 6:16:42 AM6/9/14
to google-adm...@googlegroups.com
After I upgraded to google play services I got very annoying feedbacks in short time on google play for my applications. I believe solutions mentioned here may not work on library updates or may need careful testing for different cases and may cause other problems with updates. What I know is my users are not satisfied with this problem and warning me with feedback so I want to reflect it to google and need an explanation for my users.

Thanks,
Barış 

Jan Velecký

unread,
Jun 13, 2014, 6:56:35 AM6/13/14
to google-adm...@googlegroups.com
Hello, check this one version. http://ulozto.net/xxVqc2U8/gps-rev-16-7z

Dne pondělí, 9. června 2014 12:16:42 UTC+2 Baris Efe napsal(a):

Muhammad Imran

unread,
Jul 27, 2014, 6:59:46 PM7/27/14
to google-adm...@googlegroups.com


Brother use adview in xml and set its visibility to gone and then access it in java file through findviewbyid method and then  set the listener it works for me
 <com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:visibility="gone"
    ads:adUnitId="Add_id"
    ads:adSize="BANNER"/>       

 adView = (Adview)findviewById(R.id.adview); adView.setAdListener(new AdListener() { @Override public void onAdLoaded() { adView.setVisibility(View.VISIBLE); super.onAdLoaded(); } }); adView.setVisibility(View.GONE); adView.setAdUnitId("xxx"); adView.setAdSize(AdSize.SMART_BANNER); layout = super.root; layout.addView(adView); adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest);

I.D.E.

unread,
Jul 28, 2014, 4:36:23 PM7/28/14
to google-adm...@googlegroups.com
This change in the library violates the standard Android rules for layout height.

"wrap_content" is supposed to mean "wrap content", not "fill the whole height to a predefined size, and fill it with nothing".

Kurt Müller

unread,
Sep 6, 2014, 11:15:34 AM9/6/14
to google-adm...@googlegroups.com
Hello,

can someone of the official Admob SDK Team answer to this topic?

I also have the problem that the Admob View stays blank until something is loaded. The same happens sometimes if the screen orientation gets changed => ugly blank box.
Also of course if a user has no internet connection.

So the question to the Google team:
Will this soon be fixed to finally have the same behaviour as in the old (6.4.1) SDK again?
If not it is ok to first hide the Adview and only show it if an ad could be retrieved or does this violate any rules?

thx

William Ferguson

unread,
Sep 8, 2014, 12:21:56 AM9/8/14
to google-adm...@googlegroups.com
I'm sorry, I just don't see this as an issue.

You are going to have to allocate space for your ad anyway. IMHO instead of suddenly squishing the layout when an ad becomes available it is preferable to always display the AdView and when there is no ad to display / no connection that you display nothing.

William

Kurt Müller

unread,
Sep 9, 2014, 11:56:18 AM9/9/14
to google-adm...@googlegroups.com
I cannot agree.

What should a user that has no internet connection be presented? A message that is stealing probably at least 20% of his small smartphone screen saying 'Here i'd like to show some ads but unfortunately you don't have a internet connection right now'?
Why can't it just be the same behaviour as with the old sdk?
Any again, maybe someone of Google could answer if it's ok to only show the view if there is also really an ad to display?...

Jan Velecký

unread,
Sep 9, 2014, 3:56:44 PM9/9/14
to google-adm...@googlegroups.com
@Kurt Müller: Save time, look at the this http://stackoverflow.com/q/22131006/1908192 topic, i posted there home-made solution of this GPS bug (which we cannot call bug...).

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/X4TqlA1sD6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

nr1

unread,
Sep 10, 2014, 11:02:28 AM9/10/14
to google-adm...@googlegroups.com
Thx for your answer.

However i know how to avoid showing the blank box, but the question is if Google will see this as violation of their terms or not...
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

William Ferguson

unread,
Sep 10, 2014, 5:43:45 PM9/10/14
to google-adm...@googlegroups.com
Almost certainly not. You are hiding empty space.




To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

I.D.E.

unread,
Sep 12, 2014, 3:30:55 PM9/12/14
to google-adm...@googlegroups.com
It kind of creates a poor user experience when the user sees a large empty gap near the bottom of the screen. This can be visible for a long time, if there is no Internet connection.

It's even worse when they have the on-screen keyboard showing, and there is a large gap above the keyboard.

William Ferguson

unread,
Sep 13, 2014, 12:48:03 AM9/13/14
to google-adm...@googlegroups.com
That's a matter of personal opinion.

I really hate it when am using a screen and the items I am looking at are suddenly scrunched up into new positions because a View has materialized at the bottom of the screen and consumed space.

On Sat, Sep 13, 2014 at 5:30 AM, I.D.E. <ini...@gmail.com> wrote:
It kind of creates a poor user experience when the user sees a large empty gap near the bottom of the screen. This can be visible for a long time, if there is no Internet connection.

It's even worse when they have the on-screen keyboard showing, and there is a large gap above the keyboard.

Hai Bison

unread,
Nov 4, 2014, 4:12:21 AM11/4/14
to google-adm...@googlegroups.com
I've faced this issue. I haven't used the old AdMob SDK but I do understand what you need: AdView should hide itself when there is no ads available, and show itself when ads are loaded. This should be default behavior. Every time I use AdView in a screen I have to set up something to achieve that.

There are 2 approaches:

1. Use height of 0dp

Yes it's right. Unlike "View.INVISIBLE" mode, height of 0dp will not prevent ads from being loaded. Log still shows some warnings but not errors. In details: you can set the height to 0dp directly in XML. In ad listener, just change it to WRAP_CONTENT when ads are loaded.

2. Use RelativeLayout and hide the AdView behind a matched width/height view

Requirements:
  • The root RelativeLayout should have only 2 child views: AdView and your content view.
  • Your content view must use MATCH_PARENT for both width and height.
  • Your content view must have a solid background (not transparent -- which is default, and no alpha at all). Otherwise the user can still see the AdView in this case:
    • It loaded the first ad completely, but the second ad fails to load.
    • In your AdListener you might want to hide the AdView (behind the content view) in the event that ad fails to load.
    • The second ad fails to load but it still shows the first ad. And the user can see it throughout the content view with transparent background.
  • You place the AdView at index 0 (the first child) of the RelativeLayout. When an ad is loaded, you anchor the AdView to top or bottom of the content view. When ads fail to load, you remove the anchor, and since it is the first child view, the content view (the second) will cover it.
Again I think AdMob team should make this default behavior. It will help us a lot. In short: please have the AdView hide itself until ads are loaded. And in case there is no ads at all, please hide it.

Of course no one wants to see a blank view with 50 pixels height, I'm sure it does look ugly.

Eric Leichtenschlag

unread,
Nov 4, 2014, 4:54:12 PM11/4/14
to google-adm...@googlegroups.com
The new behavior was intentionally made the default behavior to avoid the jerky behavior when an ad comes back. There are no plans to change this default behavior.

If you need to work around it, simply setting the adView to GONE until it comes back should also work.

Thanks,
Eric

Hai Bison

unread,
Nov 4, 2014, 9:15:41 PM11/4/14
to google-adm...@googlegroups.com
Thanks for the reply. Unfortunately if you set AdView visibility to GONE, it will not load ads. I'm using Google Play Services library version 6.1.71-000.

Eric Leichtenschlag

unread,
Nov 5, 2014, 6:15:49 PM11/5/14
to google-adm...@googlegroups.com
Hmm. Then another option would be to simply not put the AdView into the view hierarchy until after the ad loads.

            private boolean mAdInViewHierarchy = false;

           
...

            mAdView
.setAdListener(new AdListener() {
               
@Override
               
public void onAdLoaded() {
                   
super.onAdLoaded();
                   
if (!mAdInViewHierarchy) {
                       
RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.mainLayout);
                        mainLayout
.addView(mAdView);
                        mAdInViewHierarchy
= true;
                   
}
               
}
           
});

Hai Bison

unread,
Nov 5, 2014, 8:57:55 PM11/5/14
to google-adm...@googlegroups.com
Thank you. I'll try your suggestion.

I wish that this common task will be built-in in next version of Google Play Services library.

Hai

Sushant Patil

unread,
Jan 17, 2015, 1:15:05 AM1/17/15
to google-adm...@googlegroups.com
Thanks

It work

Contact Test

unread,
May 1, 2018, 8:50:44 PM5/1/18
to google-adm...@googlegroups.com
These changes are illogical.
- It's easier to workaround the jankiness mentioned when an ad disappears, than it is to hide/show an ad when it fails
- They didn't just change the behaviour, they made sure it wasn't possible to work around easily by not refreshing when invisible
- Not all ads affect the layout, some are on top, so the janky comments only apply to a subset of users
- Why change the behaviour to make a subset of users happy, while annoying every one else?
- Even a graduate would know to provide methods to allow developers to work around this properly

I'm sure other ad providers don't have this problem..
And they actually fix their memory leaks.


On Monday, 3 March 2014 20:21:00 UTC+11, Jan Velecký wrote:

I use GPS to provide ads in my application, but there are blank box until ad is loaded and also when user doesn't have access to te Internet and it's look awful. This is i think changed behaviour in GPS SDK in migration from dedicated AdMob SDK (which is deprecated).

I tried out set listeners for onAdLoaded, which set visibility to visible after load from gone i set after create, but there is a serious problem. This is doesn't show a blank box on application start and show ad after her load. However when there are not access to the Internet, onAdLoaded don't fired anytime because of hidden Ad! Also return these logs:
Ad is not visible. Not refreshing ad.
Scheduling ad refresh 60000 milliseconds from now.

In this situation, user never sees the ad... How can I prevent GPS Ads doing this?
There is my code placed in main activity:

 adView = new AdView(this); adView.setAdListener(new AdListener() { @Override public void onAdLoaded() { adView.setVisibility(View.VISIBLE); super.onAdLoaded(); } }); adView.setVisibility(View.GONE); adView.setAdUnitId("xxx"); adView.setAdSize(AdSize.SMART_BANNER); layout = super.root; layout.addView(adView); adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest);

Ram Parameswaran (Mobile SDK Team)

unread,
May 2, 2018, 12:33:38 PM5/2/18
to Google Mobile Ads SDK Developers
Hi,

It is intended behavior that ads will not refresh while not on screen. However, the initial ad load is possible while the ad is not in the view hierarchy or being shown on screen. You can choose to display ads only after they have successfully loaded.  

- Ram
Reply all
Reply to author
Forward
0 new messages