Skip to main content

Native/Icon

Customized ads that blend naturally with the look and feel of the app.

Overview​

Ad Types​

TypeDescription
NativeThe content area contains ad attribution, logo, main image, title, description, button, and other customizable elements. The default request count is 1 (recommended). After onAdLoaded fires successfully, display the first ad from the returned array.
IconThe content area typically contains only an icon image. The default request count is 1; the maximum count must be configured by Operations Personnel on the placement. After onAdLoaded fires, display the ads from the returned array. Supported ad source: Hisavana SSP

Sample previews from the Hisavana SSP ad source (Figure 1 and Figure 2):

Figure 1: Native

Figure 2: Icon

We recommend downloading and trying the Mediation Demo to get a more intuitive and in-depth understanding of the SDK's features and usage.

Load Ad​

Set the required parameters and listener callbacks. Pay close attention to which ad unit types each callback applies to, to avoid integration errors.

// Initialize the Native/Icon ad object; "native_id"/"icon_id" is the Native/Icon ad unit ID
TNativeAd tNativeAd = new TNativeAd(this, "native_id"/ "icon_id");
// Build the ad request body
TAdRequestBody tAdRequest = new TAdRequestBody.AdRequestBodyBuild()
.setAdListener(new TAdAlliance())
.build();
// Set the ad request body
tNativeAd.setRequestBody(tAdRequest);
// Load the ad and return the optimal ad within the configured wait time
tNativeAd.loadAd();

// Ad listener — callbacks for load, show, click, error, and close events
private static class TAdAlliance extends TAdListener {

// Load callback (applicable to: all ad units)
@Override
public void onLoad() {
// Ad loaded callback
}

// Error callback (applicable to: all ad units)
@Override
public void onError(TAdErrorCode errorCode) {
// Ad failed callback
}

// Show callback (applicable to: Native/Icon)
@Override
public void onNativeFeedShow(int source, TAdNativeInfo adNativeInfo) {
// Ad show callback
}

// Click callback (applicable to: Native/Icon)
@Override
public void onNativeFeedClicked(int source, TAdNativeInfo adNativeInfo) {
// Ad click callback
}

// Close callback (applicable to: Hisavana SSP Native/Icon)
@Override
public void onClosed(@Nullable TAdNativeInfo tAdNativeInfo) {
// Ad close callback
}

// Show error callback (applicable to: all ad units)
@Override
public void onShowError(TAdErrorCode errorCode) {
// Ad show failed callback
}
}

Reminder: source indicates the ad network. Refer to the Ad Source Correlation Table. For example, if the filled ad is from Pangle, then source = 6.

Show Ad​

Important notes:

Applicable to: Hisavana SSP ad source

Native: For ads that navigate to a PalmStore landing page, you MUST add storeMarkView (app store badge);
otherwise the download ad redirect flow will be broken.

Icon: In most cases there is no need to set a main image — only the icon needs to be set.

Reminder: To display Native ads that comply with Russian advertising regulations, see Show Russian Compliance Ads.

Step 1: Create a TAdNativeView object.​

// Add TAdNativeView in the parent layout XML
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.hisavana.mediation.ad.TAdNativeView
android:id="@+id/native_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
// Bind the view from the XML layout
TAdNativeView nativeView = findViewById(R.id.native_view);

Or

// Create TAdNativeView programmatically and add it to the parent layout
TAdNativeView nativeView = new TAdNativeView(this);

Step 2: Add the sub-layout file​

Native: Applicable to ad sources that support Native/Icon — refer to Mediation Help. Create the sub-layout file native_install.xml with the native ad elements. Use TIconView for the icon and TMediaView for the main image.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ad_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="MissingDefaultResource">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">

<!-- For ad sources that support Native/Icon; refer to "Mediation Help" -->
<com.hisavana.mediation.ad.TIconView
android:id="@+id/native_ad_icon"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="16dp">

<TextView
android:id="@+id/native_ad_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:ellipsize="end"
android:lines="1"
android:text="Title"
android:textColor="@android:color/black"
android:textSize="18sp" />

<TextView
android:id="@+id/native_ad_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="des1"
android:textColor="@android:color/black"
android:textSize="15sp" />

<!-- des2 -->
<TextView
android:id="@+id/des2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text=""
android:textColor="@android:color/black"
android:textSize="15sp" />

<RatingBar
android:id="@+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="false"
android:numStars="5"
android:stepSize="0.5" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="price" />

<TextView
android:id="@+id/likes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Likes" />

<TextView
android:id="@+id/downloads"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Downloads" />

</LinearLayout>
</LinearLayout>
</LinearLayout>

<!-- For ad sources that support Native/Icon; refer to "Mediation Help" -->
<com.hisavana.mediation.ad.TMediaView
android:id="@+id/coverview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal">

<TextView
android:id="@+id/sponsored"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:paddingLeft="16dp"
android:text="Sponsored"
android:textSize="15sp" />

<Button
android:id="@+id/call_to_action"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="DOWNLOAD NOW!"
android:textAllCaps="false" />
</LinearLayout>

</LinearLayout>

<!-- Ad attribution badge — for Hisavana SSP, Facebook, Pangle, Mintegral, Bigo -->
<com.hisavana.mediation.ad.TAdChoicesView
android:id="@+id/adChoicesView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp" />

<!-- Close button — applicable to ad sources that support Native/Icon, see "Mediation Support" for details -->
<com.hisavana.mediation.ad.TAdCloseView
android:id="@+id/adCloseView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@+id/adChoicesView" />

<!-- Close button: If you need to adapt to media style close styling, please replace TAdCloseView with ImageView on your own, provide the click event yourself, and do not need to set the adCloseView api in ViewBinder -->
<!-- <ImageView-->
<!-- android:id="@+id/adCloseView"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:src="@drawable/hs_ad_close1"-->
<!-- android:layout_toLeftOf="@+id/adChoicesView" />-->

<!-- AD label — recommended -->
<TextView
android:id="@+id/ad_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2.2dp"
android:textSize="11sp"
android:textColor="#FFFFFF"
android:background="#4D888888"
android:text="AD"/>

<!-- For Hisavana SSP: ads that navigate to a PalmStore landing page MUST include storeMarkView; otherwise the download redirect will break. -->
<com.hisavana.mediation.ad.TStoreMarkView
android:id="@+id/store_mark_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp" />
</RelativeLayout>

Icon: Applicable to the Hisavana SSP ad source. Create the sub-layout file item_icon.xml for the Icon ad elements.

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ad_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/item_background">

<com.hisavana.mediation.ad.TIconView
android:id="@+id/ad_icon"
android:layout_width="80dp"
android:layout_height="80dp"
android:scaleType="fitCenter"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

Step 3: Bind data and views​

Native: Applicable to ad sources that support Native/Icon — refer to Mediation Help.

Use the TNativeAd object to bind TAdNativeView, TAdNativeInfo, and ViewBinder together. TNativeAd holds a reference to TAdNativeView — pay close attention to the timing of TNativeAd release.

if (tNativeAd != null && tNativeAd.hasAd()) {

// Get all TAdNativeInfo objects; typically the array contains only one entry
List<TAdNativeInfo> nativeInfos = tNativeAd.getNativeAdInfo();
if (nativeInfos != null && !nativeInfos.isEmpty()) {

// For a single ad on a single page, release the previous mNativeInfo before showing the next
if (mNativeInfo != null) {
mNativeInfo.release();
}

// mNativeInfo is a page-level variable — used to release the previous ad before showing the next
// and to release resources uniformly in onDestroy()
mNativeInfo = nativeInfos.get(0);
if (mNativeInfo == null) return;

// Sub-layout info binder
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.native_install)
// Title view ID
.titleId(R.id.native_ad_title)
// Icon view ID
.iconId(R.id.native_ad_icon)
// Call-to-action view ID
.callToActionId(R.id.call_to_action)
// Description view ID
.descriptionId(R.id.native_ad_body)
// Main image view ID
.mediaId(R.id.coverview)
// Ad choices view ID
.adChoicesView(R.id.adChoicesView)
// Close view ID (Hisavana SSP only)
.adCloseView(R.id.adCloseView)
// Required: app store badge view ID
.storeMarkView(R.id.store_mark_view)
// To customise click events, call actionIds(Integer... actionIds) and pass the relevant view IDs
.actionIds(R.id.call_to_action)
.sponsoredId(R.id.sponsored)
.ratingId(R.id.rating)
.priceId(R.id.price)
.likesId(R.id.likes)
.downloadsId(R.id.downloads)
/**
* Rendering modes:
* NativeContextMode.NORMAL — standard mode
* NativeContextMode.LIST — list mode
*/
.contextMode(NativeContextMode.NORMAL)
.build();

// Check whether the ad has expired
if (mNativeInfo.isExpired()) {
AdLogUtil.Log().d("NativeAdActivity", "Ad expired");
} else {
// Bind data and views
tNativeAd.bindNativeView(nativeView, mNativeInfo, viewBinder);
}
}
}

Icon: Applicable to the Hisavana SSP ad source.

Use the TNativeAd object to bind TAdNativeView, TAdNativeInfo, and ViewBinder together. TNativeAd holds a reference to TAdNativeView — pay close attention to the timing of TNativeAd release.

if (tNativeAd != null && tNativeAd.hasAd()) {

// Get all TAdNativeInfo objects
List<TAdNativeInfo> nativeInfos = tNativeAd.getNativeAdInfo();
if (nativeInfos != null && !nativeInfos.isEmpty()) {

// When displaying multiple ads on a single page, do not release here; release uniformly in onDestroy()
if (mNativeInfo != null) {
mNativeInfo.release();
}

// This example shows a single Icon ad on a single page; for multiple icons, use RecyclerView
mNativeInfo = nativeInfos.get(0);
if (mNativeInfo == null) return;

// Sub-layout info binder
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.item_icon)
// Icon view ID
.iconId(R.id.ad_icon)
/**
* Rendering modes:
* NativeContextMode.NORMAL — standard mode
* NativeContextMode.LIST — list mode
*/
.contextMode(NativeContextMode.NORMAL)
.build();

// Check whether the ad has expired
if (mNativeInfo.isExpired()) {
AdLogUtil.Log().d("NativeAdActivity", "Ad expired");
} else {
// Bind data and views
tNativeAd.bindNativeView(nativeView, mNativeInfo, viewBinder);
}
}
}
/**
* Optional
* For apps that need to track ad scene impressions, set the scene value here.
* The first parameter is a custom scene name; the second is the ad count.
*/
String sceneToken = tNativeAd.enterScene("native_scene_name", 1);
tNativeAd.bindNativeView(nativeView, mNativeInfo, viewBinder, sceneToken);

List Scene​

The following applies to Native ads.

Define a data class to store nativeInfo and sceneToken:

public class ItemBean {
private TAdNativeInfo nativeInfo;
private TNativeAd nativeAd;
public String sceneToken;
}

Bind the layout in the list:

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vhHolder, int position) {
ItemBean itemBean = data.get(position);
// Track scene utilization; first param is custom scene name, second is ad count
if (TextUtils.isEmpty(itemBean.sceneToken)) {
itemBean.sceneToken = tNativeAd.enterScene("native_scene_name", 1);
}
List<TAdNativeInfo> nativeInfos = tNativeAd.getNativeAdInfo();
itemBean.nativeInfo = (nativeInfos == null || nativeInfos.isEmpty()) ? null : nativeInfos.get(0);
if (itemBean.nativeInfo == null || itemBean.nativeInfo.isExpired()) {
// Reload the ad
return;
}
// Build ViewBinder
// ...
// Show ad
itemBean.nativeAd.bindNativeView(nativeView, itemBean.nativeInfo, viewBinder, itemBean.sceneToken);
}

Destroy Ad​

Release ad resources promptly to prevent memory leaks.

// This callback is for the Hisavana SSP ad source. It is recommended to release resources uniformly in onDestroy().
// This callback will be removed in a future version.
@Override
public void onClosed(TAdNativeInfo tAdNativeInfo) {
/**
* When the user taps the close button, release the ad resources.
* In a list scenario, use tAdNativeInfo to locate the ad's position and remove it dynamically.
*/
if (tAdNativeInfo == mNativeInfo) {
if (mNativeInfo != null) {
mNativeInfo.release();
}
if (nativeView != null) {
nativeView.release();
}
mNativeInfo = null;
nativeView = null;
}
}

The example below covers releasing a single Native/Icon ad on a single page. For multiple Native/Icon ads, manage and release all resources uniformly in onDestroy() — the objects to release are TNativeAd, TAdNativeInfo, and TAdNativeView. Refer to the Mediation Demo for details.

// Destroy the ad object when leaving the ad scene.
@Override
protected void onDestroy() {
if (tNativeAd != null) {
tNativeAd.destroy();
tNativeAd = null;
}
if (mNativeInfo != null) {
mNativeInfo.release();
}
if (nativeView != null) {
nativeView.release();
}
mNativeInfo = null;
nativeView = null;
super.onDestroy();
}

Other APIs​

APIDescription
tNativeAd.hasAd()Whether a ready ad is available
mNativeInfo.isExpired()Check whether the ad is within its delivery period; call before displaying the ad

Advanced Settings​

Hisavana SSP
Yandex
Others

Required Ad Elements​

Hisavana SSPAdmobFacebookPangleMintegralYandexBigo
Media(mediaId)RequiredRequiredRequiredRequiredRequiredRequiredOptional
AdChoices(adChoicesView)RequiredAdmob renders itselfRequiredRequiredRequiredNoneOptional
Title(titleId)OptionalRequiredRequiredRequiredRequiredRequiredOptional
Icon(iconId)OptionalRequiredRequiredRequiredRequiredRequiredOptional
Close Button(adCloseView)OptionalAdd it yourself
(Google recommends that it is required)
NoneNoneNoneNoneNone
Store Mark Icon(adStoreMarkView)RequiredNoneNoneNoneNoneNoneNone
Description(descriptionId)OptionalOptionalOptionalRequiredRequiredOptionalOptional
Button(callToActionId)OptionalRequiredRequiredRequiredRequiredRequiredOptional
Rating(ratingId)OptionalOptionalNoneNoneNoneOptionalNone
Price(priceId)NoneOptionalNoneNoneNoneRequiredNone
Sponsored(sponsoredId)NoneNoneNoneNoneNoneRequiredNone
Disclaimer(adDisclaimerView)RU RequiredNoneNoneNoneNoneRequiredNone
RU Compliance AD identifier(adBadgeView)RU RequiredNoneNoneNoneNoneNoneNone
Domain(domainId)NoneNoneNoneNoneNoneRequiredNone
Feedback(feedbackId)NoneNoneNoneNoneNoneRequiredNone

Show Russian Compliance Ads​

Developers whose products are published in Russia and who monetize via mediation-lib (with the mediation-lib SDK integrated) must comply with Russian advertising laws.

mediation-lib SDK 3.0.8 and above supports displaying Russian-compliant ads. When rendering self-rendered Native ads, additional integration steps are required. This applies to the Hisavana SSP ad source.

The main integration differences are in Step 2 and Step 3 of the Show Ad section: you must replace the AD badge view and add a Disclaimer view.

Reminder: "Standard version" below refers to the non-Russian-compliance version.

Step 1: Create a TAdNativeView object.​

Same as above.

Step 2: Add the sub-layout file​

Create the sub-layout file native_install.xml with the native ad elements. Use TIconView for the icon and TMediaView for the main image.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ad_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="MissingDefaultResource">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">

<com.hisavana.mediation.ad.TIconView
android:id="@+id/native_ad_icon"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="16dp">

<TextView
android:id="@+id/native_ad_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:ellipsize="end"
android:lines="1"
android:text="Title"
android:textColor="@android:color/black"
android:textSize="18sp" />

<TextView
android:id="@+id/native_ad_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="des1"
android:textColor="@android:color/black"
android:textSize="15sp" />

<!-- des2 -->
<TextView
android:id="@+id/des2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text=""
android:textColor="@android:color/black"
android:textSize="15sp" />

<RatingBar
android:id="@+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="0.5"
android:isIndicator="false"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="price" />

<TextView
android:id="@+id/likes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Likes" />

<TextView
android:id="@+id/downloads"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Downloads" />

</LinearLayout>
</LinearLayout>
</LinearLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.hisavana.mediation.ad.TMediaView
android:id="@+id/coverview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<!-- Required: Russian compliance disclaimer view -->
<com.hisavana.mediation.ad.TAdDisclaimerView
android:id="@+id/ad_disclaimer_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>

</FrameLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal">

<TextView
android:id="@+id/sponsored"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:paddingLeft="16dp"
android:text="Sponsored"
android:textSize="15sp" />

<Button
android:id="@+id/call_to_action"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="DOWNLOAD NOW!"
android:textAllCaps="false" />
</LinearLayout>

</LinearLayout>

<!-- Ad attribution badge -->
<com.hisavana.mediation.ad.TAdChoicesView
android:id="@+id/adChoicesView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp" />

<!-- Close button — applicable to ad sources that support Native/Icon, see "Mediation Support" for details -->
<com.hisavana.mediation.ad.TAdCloseView
android:id="@+id/adCloseView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@+id/adChoicesView" />

<com.hisavana.mediation.ad.TStoreMarkView
android:id="@+id/store_mark_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />

<!-- Required: Russian compliance AD badge — Hisavana SSP only -->
<com.hisavana.mediation.ad.TAdBadgeView
android:id="@+id/ad_badge_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</RelativeLayout>

Step 3: Bind data and views​

Use the TNativeAd object to bind TAdNativeView, TAdNativeInfo, and ViewBinder together. TNativeAd holds a reference to TAdNativeView — pay close attention to the timing of TNativeAd release.

if (tNativeAd != null && tNativeAd.hasAd()) {

// Get all TAdNativeInfo objects; typically the array contains only one entry
List<TAdNativeInfo> nativeInfos = tNativeAd.getNativeAdInfo();
if (nativeInfos != null && !nativeInfos.isEmpty()) {

// For a single ad on a single page, release the previous mNativeInfo before showing the next
if (mNativeInfo != null) {
mNativeInfo.release();
}

mNativeInfo = nativeInfos.get(0);
if (mNativeInfo == null) return;

// Sub-layout info binder
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.native_install)
// Title view ID
.titleId(R.id.native_ad_title)
// Icon view ID
.iconId(R.id.native_ad_icon)
// Call-to-action view ID
.callToActionId(R.id.call_to_action)
// Description view ID
.descriptionId(R.id.native_ad_body)
// Main image view ID
.mediaId(R.id.coverview)
// Ad choices view ID
.adChoicesView(R.id.adChoicesView)
// Required: Russian compliance AD badge
.adBadgeView(R.id.ad_badge_view)
// Close view ID (Hisavana SSP only)
.adCloseView(R.id.adCloseView)
// Required: app store badge view ID
.storeMarkView(R.id.store_mark_view)
// To customise click events, call actionIds(Integer... actionIds) and pass the relevant view IDs
.actionIds(R.id.call_to_action)
.sponsoredId(R.id.sponsored)
.ratingId(R.id.rating)
.priceId(R.id.price)
.likesId(R.id.likes)
.downloadsId(R.id.downloads)
// Required: Russian compliance disclaimer
.adDisclaimerView(R.id.ad_disclaimer_view)
/**
* Rendering modes:
* NativeContextMode.NORMAL — standard mode
* NativeContextMode.LIST — list mode
*/
.contextMode(NativeContextMode.NORMAL)
.build();

// Check whether the ad has expired
if (mNativeInfo.isExpired()) {
AdLogUtil.Log().d("NativeAdActivity", "Ad expired");
} else {
// Bind data and views
tNativeAd.bindNativeView(nativeView, mNativeInfo, viewBinder);
}
}
}
/**
* Optional
* For apps that need to track ad scene impressions, set the scene value here.
* The first parameter is a custom scene name; the second is the ad count.
*/
String sceneToken = tNativeAd.enterScene("native_scene_name", 1);
tNativeAd.bindNativeView(nativeView, mNativeInfo, viewBinder, sceneToken);