Admob bug? missing functionality? VSIBILE/GONE -> Ad is not visible. Not refreshing ad.

257 views
Skip to first unread message

TomDev

unread,
Mar 28, 2016, 6:40:05 PM3/28/16
to Google Mobile Ads SDK Developers
Hello,

I used to use Admob stand-alone library 6.4.x. It had built-in functionality of changing visible/gone attribute of the ad's view. I've just switched to Google Play Services library (rev. 29 ; 8487000) and noticed that this functionality is not supported any more. In this case, to avoid seeing ugly empty box when the ad is not loaded, I implemented my solution with AdListener:

onCreate() {
(...)
adView.setVisibility(View.GONE);
adView.setAdListener(new AdListener() {

            @Override
            public void onAdLoaded() {
                adView.setVisibility(View.VISIBLE);
            }
});
(...)
}

Now we have 3 following scenerios:

a) Internet on -> application starts (calls onCreate of the activity) -> ad loads -> adView: visible -> we can see the ad
b) Internet off -> application starts (calls onCreate of the activity) -> click on home button (moves app to the background) -> Internet on -> application recures (moves from the background to the foreground: calls onStart()/onResume() without onCreate()) -> after 60 sec we get message: "Ad is not visible. Not refreshing ad." (AdListener:onAdLoaded() hasn't been called)
c) Internet off -> applicaiton starts (calls onCreate of the activity) -> pull down the notificiation bar (we are still in the app) -> Internet on -> after 60 sec we get message: "Ad is not visible. Not refreshing ad." (AdListener:onAdLoaded() hasn't been called)

On (b) and (c) scenerio the ad starts to refresh: "Scheduling ad refresh 60000 milliseconds from now" but after 60 sec we get the message: "Ad is not visible. Not refreshing ad.".
Maybe we should have additional interface method which is called before AdView checks its visiblity, e.q. onAdDownloaded() ? So I could move adView.setVisibility(View.VISIBLE) from onAdLoaded() to onAdDownloaded().


After my several test I assume the problem is with calling loadAd(AdRequest). If I call adView.loadAd(adRequest) in onCreate() (Activity) method the ad will be displayed correctly. But if the request of the ad is triggered by admob itself:  from adView.resume() or inner broadcast reciver (android.net.conn.CONNECTIVITY_CHANG) I will get the message: "Ad is not visible. Not refreshing ad."

Cheers,
Tom

Veer Arjun Busani(Mobile Ads SDK Team)

unread,
Mar 29, 2016, 10:24:46 AM3/29/16
to Google Mobile Ads SDK Developers
Hi Tom,

If you want to toggle the visibility of the AdView, then I would suggest you to call destroy() when you want to hide it and make a new AdRequest when you want to show it. But if still want to use setVisibility(), then do not hide the AdView before you are able to load the Ad. Make sure you load it first and then hide is as you want. It would not be visible in any case if there is no Ad in the first place. If the Ad is already loaded and then you come back from the background, check if there is any Ad loaded and hide it. If not make a new Ad Request and hide it. 

If you loose connectivity, then onAdFailedToLoad() would be called. You can then wait to get the connectivity back and make a new AdRequest. 

Thanks,
Veer Busani
Mobile Ads SDK Team 
Reply all
Reply to author
Forward
0 new messages