Login
Welcome
Login

Native Ad - Classic integration

This page explains how to integrate a Teads native placement into your Android application.

  1. Prerequisites
  2. Implementation
  3. Event monitoring
  4. Check list
  5. Additional Settings

Prerequisites

Implementation

Important

Make sure you are using a dedicated native placement id (PID) on native ad requests, do not reuse inRead PID. You will not receive any ad if the PID is not a native one.

The article is using the native test PID 124859. This PID is meant for testing purpose and shall not be released into production.

Please retrieve your production PID from your local account manager.

Add the NativeAdView view to your layout

<?xml version="1.0" encoding="utf-8"?>
<tv.teads.sdk.renderer.NativeAdView
  android:id="@+id/nativeAdView"
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

  <TextView
    android:id="@+id/teads_native_title"
    ...
  />

    <tv.teads.sdk.renderer.MediaView
    android:id="@+id/teads_native_media"
    ...
  />
</tv.teads.sdk.renderer.NativeAdView>

Native Elements

The native ad supports these following elements within the NativeAdView container:

  • R.id.teads_native_title (TextView) (Guaranteed in every request)
  • R.id.teads_native_content (TextView)
  • R.id.teads_native_media (MediaView) (Guaranteed in every request)
  • R.id.teads_native_icon (ImageView)
  • R.id.teads_native_advertiser (TextView)
  • R.id.teads_native_call_to_action (Button)
  • R.id.teads_native_star_rating (View)
  • R.id.teads_native_price (TextView)

Load an Ad

class MainActivity : AppCompatActivity(), NativeAdListener {
  private lateinit var adPlacement: NativeAdPlacement

  private lateinit var inFeedBasicBinding: ActivityInFeedBasicBinding

  override fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    inFeedBasicBinding = ActivityInFeedBasicBinding.inflate(layoutInflater)
    setContentView(inReadBasicBinding.root)

    val placementSettings = AdPlacementSettings.Builder().build()
    val requestSettings = AdRequestSettings.Builder().build()

    adPlacement = TeadsSDK.createNativePlacement(applicationContext, 124859, placementSettings)
    adPlacement.requestAd(requestSettings, this)
  }

  override fun onAdReceived(nativeAd: NativeAd) {
    nativeAd.setNativeAdListener(this)

    with (inFeedBasicBinding.containerAdView) {
        nativeAdView.teadNativeMedia.mediaScale = MediaScale.CENTER_CROP // Set it as CENTER_CROP (default) or CENTER_INSIDE
        nativeAdView.bind(nativeAd)
    }
  }

  override fun onFailToReceiveAd(error: String) {}

  override fun adOpportunityTrackerView(trackerView: AdOpportunityTrackerView) {
    inFeedBasicBinding.containerAdView.nativeAdView.addView(trackerView)
  }
}

Event monitoring

The Teads inApp SDK provides a set of listeners to let you monitor a large scope of events all along ad life cycle. This helps tailor the ad experience in your app, e.g., closing the ad view in case of onAdError.

interface NativeAdListener {
  // When an impression has occurred
  fun onAdImpression(nativeAd: NativeAd)

  // When an event click has been fired
  fun onAdClicked(nativeAd: NativeAd)

  // When the ad experience has experienced an issue
  fun onAdError(nativeAd: NativeAd, code: Int, description: String)

  // This is the entry point of an Ad correctly loaded by Teads
  fun onAdReceived(nativeAd: NativeAd)

  // When Teads inApp SDK has failed to retrieve an ad
  fun onFailToReceiveAd(failReason: String)

  // This is the monitoring slot tracker view (see Slot Monitoring section below)
  fun adOpportunityTrackerView(trackerView: AdOpportunityTrackerView)
}

Check list

  • ✅ Ensure Brand Safety is enabled
  • ✅ Ensure you comply with privacy legal requirements (GDPR/CCPA/GPP)
  • ✅ Comply with app-ads.txt
  • ✅ Test different PIDs with various ad formats and sizes
  • ✅ Enable validation mode to ensure key features are working

Additional Settings

Find the full available AdPlacementSettings and AdRequestSettings settings here:

Example:

AdPlacementSettings.Builder()
  // Enable debug logs
  .enableDebug()
  // GDPR
  .userConsent([SUBJECT_TO_GDPR], [CONSENT_STRING], TCFVersion.V2, sdkId)
  .build()

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.