Ad finished loading but banner stays white

699 views
Skip to first unread message

Bevor

unread,
Jan 11, 2015, 10:46:51 AM1/11/15
to google-adm...@googlegroups.com
I try to add a BANNER ad to an own implementation of GoogleMap.InfoWindowAdapter. I think I have everything correctly, the debuggers shows "Ad finished loading" but the banner on the snippet, where I show the add, stays white. Nothing shown at all. (I chose getInfoWindow() method to be sure that the view is exactly the view I defined in the xml).

This is my custom implementation of the adapter.

public class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter
{
   
private static final String TAG = CustomInfoWindowAdapter.class.getSimpleName();

   
private LayoutInflater inflater = null;
   
private Context context;

   
private static final String DEVICE_ID_ZTE = "14212121212121212121121212";
   
private static final String DEVICE_ID_MOTO_G = "565645543543434343434343";

   
public CustomInfoWindowAdapter(Context context)
   
{
        inflater
= (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       
this.context = context;
   
}

   
@Override
   
public View getInfoContents(Marker marker)
   
{
       
return null;
   
}

   
@Override
   
public View getInfoWindow(Marker marker)
   
{
       
Logger.log(TAG, "getInfoWindow()", LogController.isLoggingEnabled(), Log.DEBUG);
       
View popup = inflater.inflate(R.layout.popup, null);

       
AdView adView = (AdView)popup.findViewById(R.id.adView);
       
AdRequest adRequest = new AdRequest.Builder().addTestDevice(DEVICE_ID_MOTO_G).addTestDevice(DEVICE_ID_ZTE).build();
        adView
.loadAd(adRequest);
        adView
.setVisibility(View.VISIBLE);

       
//more common code

       
return popup;
   
}
}

This is the xml of the popup:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:ads="http://schemas.android.com/apk/res-auto"
   
android:layout_width="320dp"
   
android:layout_height="wrap_content"
   
android:orientation="vertical"
   
android:background="#B3FFFFFF" >

   
<TextView
       
android:id="@+id/title"
       
android:layout_width="wrap_content"
       
android:layout_height="wrap_content"
       
android:textColor="@color/snippet_text_color"
       
android:textSize="18sp"
       
android:textStyle="bold" />

   
<TextView
       
android:id="@+id/snippet"
       
android:layout_width="wrap_content"
       
android:layout_height="wrap_content"
       
android:textColor="@color/snippet_text_color"
       
android:textSize="12sp" />

   
<RelativeLayout
       
android:layout_width="match_parent"
       
android:layout_height="match_parent" >

       
<com.google.android.gms.ads.AdView
           
android:id="@+id/adView"
           
android:layout_width="match_parent"
           
android:layout_height="wrap_content"
           
android:layout_centerHorizontal="true"
           
ads:adSize="BANNER"
           
ads:adUnitId="ca-app-pub-foooooooo/baaaaaar" >
       
</com.google.android.gms.ads.AdView>
   
</RelativeLayout>

</LinearLayout>


I'm using Google play Services SDK 6.5.87. It's no problem on the device, because I have the same problems on Moto G (Android 4.4) and ZTE (Android 2.3.7).

Any ideas about this?

Bevor

unread,
Jan 12, 2015, 1:00:13 PM1/12/15
to google-adm...@googlegroups.com
I just figured something out:

When I put all the ad initialization and invocation into the ctor, just for testing, it doesn't show any add when I open the snippet the first time. When I open the snippet a second time, the ad suddendly is shown. I don't understand what's the problem with that.

Bevor

unread,
Jan 12, 2015, 3:19:10 PM1/12/15
to google-adm...@googlegroups.com
Either I don't understand how to use AdMob or this is totally buggy. Please see the current code:

public class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter
{
   
private static final String TAG = CustomInfoWindowAdapter.class.getSimpleName();

   
private LayoutInflater inflater = null;
   
private Context context;

   
private View popup;
   
private AdView adView;
   
private AdRequest adRequest;
   
private long lastUpdateInterval;

   
public static final String DEVICE_ID_ZTE = "1111111111111111111111111";
   
public static final String DEVICE_ID_MOTO_G = "22222222222222222222222222";

   
public CustomInfoWindowAdapter(Context context)
   
{
       
this.context = context;

        inflater
= (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        popup
= inflater.inflate(R.layout.popup, null);
        adView
= (AdView)popup.findViewById(R.id.adView);
        adRequest
= new AdRequest.Builder().addTestDevice(DEVICE_ID_MOTO_G).addTestDevice(DEVICE_ID_ZTE).build();

   
}

   
@Override
   
public View getInfoContents(Marker marker)
   
{
       
return null;
   
}

   
@Override
   
public View getInfoWindow(Marker marker)
   
{
       
Logger.log(TAG, "getInfoWindow()", LogController.isLoggingEnabled(), Log.DEBUG);


       
if (System.currentTimeMillis() - 30000 > lastUpdateInterval)
       
{
           
Logger.log(TAG, "last update was more than 30s behind. loading new ad request...", LogController.isLoggingEnabled(), Log.DEBUG);

            adView
.loadAd(adRequest);
            lastUpdateInterval
= System.currentTimeMillis();
       
}

       
Logger.log(TAG, "refreshing adView...", LogController.isLoggingEnabled(), Log.DEBUG);

        adView
.requestLayout();

       
return popup;
   
}
}

and the XML...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:ads="http://schemas.android.com/apk/res-auto"
   
android:layout_width="320dp"
   
android:layout_height="wrap_content"

   
android:background="#B3FFFFFF"
   
android:orientation="vertical" >


   
<TextView
       
android:id="@+id/title"
       
android:layout_width="wrap_content"
       
android:layout_height="wrap_content"
       
android:textColor="@color/snippet_text_color"
       
android:textSize="18sp"
       
android:textStyle="bold" />

   
<TextView
       
android:id="@+id/snippet"
       
android:layout_width="wrap_content"
       
android:layout_height="wrap_content"
       
android:textColor="@color/snippet_text_color"
       
android:textSize="12sp" />


   
<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="ca-app-pub-12121212/23232323" >
   
</com.google.android.gms.ads.AdView>

</LinearLayout>



First oft all, and additional issue I observed before (not that code above): Although automatically update configuration in AdMob page was set to "autmatically", and although the snippet with the ad was open more than one minute the log showed me "Ad is not visibible. Not refreshing ad"!
Secondly, with the code from above, I set "automatically refresh" to NO. But I still see log messages like "Ad is not visible. Not refreshing ad." Why does it do that. I said no refresh!

My plan with the code from above is that I manually reload ads if the user opens a snippet on Google Maps while clicking on a marker. Although the ads loads very slow, and not are not always shown, this could basically work, although I always see the same test banner. How can I be sure if the real banner loads a new ad from time to time, because I must not test without test mode?
But what's really annoying, I can't click the banner! There is no log entry, nothing. So not even clicking the banner works. What did I do wrong, or is this so buggy?

Bevor

unread,
Jan 13, 2015, 2:47:43 PM1/13/15
to google-adm...@googlegroups.com
Now I know what's going on here. The snippet is rendered as an image onto the Google Map. Hence it's no "real" view and obviously that's why AdMob doesn't work properly here. It seems that I have to find another solution.

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Jan 13, 2015, 4:57:48 PM1/13/15
to google-adm...@googlegroups.com
That is indeed the issue.  By the time AdMob successfully loads the ad, the popup has already been rendered and displayed.  There is, though, a great Stack Overflow post on this issue, which details some techniques for refreshing the window adapter after a download:


-Andrew

Bevor

unread,
Jan 14, 2015, 1:57:25 AM1/14/15
to google-adm...@googlegroups.com
I think the only solution is to defined a placeholder within the snippet and to overlay this placeholder with a dynamically added fragment, so that it looks for the user that the banner is inside the snippet although it's above the snippet. That's kind of dirty, but I'm sure this is the only working solution.
Reply all
Reply to author
Forward
0 new messages