Show Sidebar

Requesting Native Ads – Android SDK without Helper Libraries

Sorry, this entry is only available in English. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

It is recommended to use the VMAX Helper Library.

Alternatively, you can use getter functions to render a Native Ad. Once the native ad is cached, the native images are downloaded and as ImageView once the success callbacks is received on onAdReady().

To Fetch Native Ad always only use cacheAd(). No need to call showAd() or loadAd() for invoking Native Ads. Once you call the cacheAd() API for native ad you will get callback of native ad in onAdReady().

Use the sample below for rendering native ads in your own layout.

Note: For AdMob AdChoice View icon, pass second parameter in above function that is Ad container Layout and keep top right space empty say 15px. VMAX SDK will handle to render AdMob Adchoice icon for AdMob. For Facebook follow below table.

Parameter Recommended Description
nativeAd.getTitle();  Yes  the title property of the ad
nativeAd.getDesc();  Yes  the description property of the ad
nativeAd.getCtaText();  Yes  the call to action title property of the ad
nativeAd.getRating();  Optional
nativeAd.getMediaView();  Yes to be used only for Facebook and Vserv Ads
nativeAd.getNativeAdPartner();  Yes to get Ad partner
nativeAd.getAdChoiceUrl();  Yes to be used only for Facebook
nativeAd.getObjective();  Optional
nativeAd.getVastVideoTag();  Optional
nativeAd.getDesc2();  Optional
nativeAd.getPrice();  Optional
nativeAd.getDownloads();  Optional
nativeAd.getAdChoiceView();  Yes  getAdChoiceView() used only for Facebook. While using this Adchoice view of Facebook than ignore getAdChoiceUrl().It automatically handles click on it.
nativeAd.getNativeAdType();  Optional
nativeAd.getSalePrice();  Optional
nativeAd.getSponsored();  Optional
nativeAd.getLikes();  Optional
nativeAd.getPhone();  Optional
nativeAd.getAddress();  Optional
nativeAd.getDisplayurl();  Optional
nativeAd.getIcon().getUrl();  Yes
nativeAd.getImageMain().getImageView();  Yes(Any One image)  Check If MainImage available use it. If not follow below images(Priority check should be ImageMain,ImageMedium,ImageTile and ImageBanner )
 Yes(Any One image)
 Yes(Any One image)
 Yes(Any One image)
 Yes(Any One image)
 To be used only for Facebook. Make use of getAdChoiceUrl() so as to set click on ImageView.

Additional notes for InMobi Native Ads

From InMobi version 6.0.0 (supported from VMAX Android SDK v3.5.19), InMobi returns a ‘screenshots’ element on their dashboard as shown in the accompanying image.


  • If you select an image with aspectRatio ‘1.91’, this is mapped to the ‘imageMain’ element of the Native Ad object. Thus, requesting for imageMedium will result in a nil value.
  • If you select an image with aspectRatio ‘1’, this is mapped to the ‘imageMedium’ & ‘imageTile’ elements of the Native Ad object. Thus, requesting for imageMain will result in a nil value.

As a best practice, you should always check if the requested element is nil or not and for non-nil, use the native ad element in rendering your custom native ad layout.

Ad Network Policies

In addition, you need to adhere to the policies shared by AdMob and Facebook here:

If using any ad network other that AdMob or Facebook, be sure to include an Ad symbol so that app users can identify that it’s an ad. The below example shows a test ad from VMAX having an icon, large image, title, CTA button and the ad attribution symbol in the top right.


Once all elements are assigned to Ad parentview and just when your Ad parentView is visible use below function to track impressions and clicks. No need to set any listener on Ad. This function is very important used only when native Ads rendering is without helper libraries.

SDK 3.6.0 onwards

Before SDK 3.6.0


adView is mandatory for proper handling of Native Ads.
vgroup is mandatory main Ad parnetView.
view is mandatory so as to set listener, it should be CTA view or any other Native Ad element view.
listview is Optional if click on multiple views required. If listview is provided than third argument View view should be parent of the view available in list.

Note: Refer NativeAdConstants class for standard native element name to map to mediation partners like InMobi.

Important Note: Make sure you follow proper Mediation partner Guidelines while working with VMAX Native without helper libraries.

Admob Guidelines: https://support.google.com/admob/answer/6329638?rd=1

Facebook Guidelines: https://developers.facebook.com/docs/audience-network/guidelines/native-ads

Add vmax_custom_native_layout.xml in your Layouts

Add below code in your Activity class

SDK 3.6.0 onwards

Before SDK 3.6.0

What would you like to do next?