AdChoicesView works differently in Native ad express vs Native ad advanced

262 views
Skip to first unread message

Maxim Ilyukhin

unread,
Jan 27, 2018, 8:58:19 PM1/27/18
to Google Mobile Ads SDK Developers
I am following two google sample repositories to compare the behaviour of Native Ad Express and Native Ad Advanced
I just checked out the projects and imported to Android Studio with no changes.

The attached screenshots is the outcome of what I'm getting. Notice that AdChoicesView (right top corner) is slightly different.
For Native Express (see navExpress.png) it's contains two icons "i" and "x", but in Native Advanced (see navAdvanced.png) there is no "x" (responsible for closing ad).

I believe, in Native Express code we don't have much control over the views, so the code there is pretty straight forward.
Unlike in Native Advanced code, where we are setting all the views explicitly:

adView.setHeadlineView(adView.findViewById(R.id.contentad_headline));
...
adView.setAdvertiserView(adView.findViewById(R.id.contentad_advertiser));

then a value for them:

((TextView) adView.getHeadlineView()).setText(nativeContentAd.getHeadline());
...
((TextView) adView.getAdvertiserView()).setText(nativeContentAd.getAdvertiser());

and assigning the ad to the view (whatever it means :)) :

adView.setNativeAd(nativeContentAd);


On the attached screenshot for layout inspector I see that there is a FrameLayout injected in case of Native Advanced Example, and there is only one image, for "i" icon (see adViewLayout.png).
Moreover, in my project the AdChoices icons don't appear at all. What are the rules to get it appear on my layout?
Is there something additional I need to do in order to get the close to Native Express behaviour?

I was trying to reinvent the wheel by adding AdChoicesView to my FrameLayout:

<com.google.android.gms.ads.formats.AdChoicesView
    android:id="@+id/ad_choices_info"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="top|end">

</com.google.android.gms.ads.formats.AdChoicesView>

and then set it within the setter:

adView.setAdChoicesView((AdChoicesView) adView.findViewById(R.id.ad_choices_info));

But no luck.
Could you please guide me on that. Thanks

----
Max


navExpress.png
navAdvanced.png
adViewLayout.png

Tech Update

unread,
Jan 28, 2018, 6:19:34 AM1/28/18
to Google Mobile Ads SDK Developers
Hey you do you get native ads id because when i click create ads unit i didn't find native ads option .. how to avail that please provide all info.

mobileadssdk-a...@google.com

unread,
Jan 29, 2018, 2:35:17 AM1/29/18
to Tech Update, Google Mobile Ads SDK Developers
Hi Max,

Below are my responses to your questions.

adView.setNativeAd(nativeContentAd);


As per this guide, the setNativeAd() method registers the Native ad object with the view that's responsible for displaying and handling it.

Moreover, in my project the AdChoices icons don't appear at all. What are the rules to get it appear on my layout?
Is there something additional I need to do in order to get the close to Native Express behaviour?

As per this guide, the AdChoices overlay and its contents is automatically added to the AdView by the SDK. You may only change which corner the AdChoices overlay is rendered in by setting this property via setAdChoicesPlacement(). However, kindly note that editing the contents of the AdChoices overlay is not available via the Mobile Ads SDK. You may also refer to this Help Center article for more relevant information.

As for other publishers who wish to get access to the Native Advanced Ads feature, please note that this is currently available only to selected publishers. If it's not yet available on your end, then we suggest that you keep an eye on our blog for any future updates.

Regards,
Ivan Bautista
Mobile Ads SDK Team

Maxim Ilyukhin

unread,
Jan 30, 2018, 3:15:41 AM1/30/18
to Google Mobile Ads SDK Developers
@Tech Update those are just examples from google repository, clone and run..

Thanks @Ivan for your response.

Could you please clarify how to get the close ad button with Native Advanced Ads, as it's not coming with the content of AdChoices overlay by default (screenshot navAdvanced.png). Like it happens in the example with Native Express Ad (screenshot navExpress.png, top left corner).
Should I be implementing my own closing ad behaviour for a shown ad?

Thanks

mobileadssdk-a...@google.com

unread,
Jan 30, 2018, 5:16:03 AM1/30/18
to Maxim Ilyukhin, Google Mobile Ads SDK Developers
Hi Max, 

Apologies if I wasn't clear in my previous response. Please note that the Mobile Ads SDK doesn't allow you to edit the contents of the AdChoices overlay. The only thing you can do via the Mobile Ads SDK is to change which corner the AdChoices overlay is rendered in by setting the property via setAdChoicesPlacement().

The AdChoices overlay and its contents (whether it contains the AdChoices icon or the Ads by Google icon and without the "x" button) is added to the AdView by the Mobile Ads SDK automatically and whatever it is that is returned as contents of the AdChoices overlay will be the one displayed as is. 

You may implement your own closing behavior (just be mindful of the implementation guidelines here and here) as you see fit to your requirements. On the other hand, when you are done showing your native ad, you could destroy the ad via nativeAd.destroy().
Reply all
Reply to author
Forward
0 new messages