Banner Placement
Banner placements display an anchored banner ad inline in your layout. In the direct integration the JS engine drives the banner height — set the container height to wrap_content and it resizes as the creative loads.
The official Teads SDK sample application includes working examples of this format. Use it for implementation examples and as a reference while you set up this placement.
Example
<!-- res/layout/activity_main.xml -->
<FrameLayout
android:id="@+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
- Kotlin
- Java
import android.os.Bundle
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import tv.teads.sdk.combinedsdk.TeadsAdPlacementEventName
import tv.teads.sdk.combinedsdk.adplacement.TeadsAdPlacementBanner
import tv.teads.sdk.combinedsdk.adplacement.config.TeadsAdPlacementBannerConfig
import tv.teads.sdk.combinedsdk.adplacement.interfaces.TeadsAdPlacementEventsDelegate
import tv.teads.sdk.combinedsdk.adplacement.interfaces.core.TeadsAdPlacement
class BannerActivity : AppCompatActivity(), TeadsAdPlacementEventsDelegate {
private var banner: TeadsAdPlacementBanner? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// 1. Build the placement configuration
val config = TeadsAdPlacementBannerConfig(
articleUrl = "https://yoursite.com/article".toUri(),
widgetId = "MB_10", // Provided by your Teads account manager
installationKey = "YOUR_INSTALLATION_KEY",
widgetIndex = 0
)
// 2. Create the placement and load the ad — context (this) MUST be an Activity
val placement = TeadsAdPlacementBanner(this, config, this)
banner = placement
// 3. Attach the returned view to your container
val adView = placement.loadAd()
findViewById<FrameLayout>(R.id.banner_container).addView(adView)
}
override fun onPlacementEvent(
placement: TeadsAdPlacement<*, *>,
event: TeadsAdPlacementEventName,
data: Map<String, Any>?
) {
// React to placement lifecycle events — see Placement Events Listener for the full event reference.
}
}
import android.net.Uri;
import android.os.Bundle;
import android.widget.FrameLayout;
import androidx.appcompat.app.AppCompatActivity;
import tv.teads.sdk.combinedsdk.TeadsAdPlacementEventName;
import tv.teads.sdk.combinedsdk.adplacement.TeadsAdPlacementBanner;
import tv.teads.sdk.combinedsdk.adplacement.config.TeadsAdPlacementBannerConfig;
import tv.teads.sdk.combinedsdk.adplacement.interfaces.TeadsAdPlacementEventsDelegate;
import tv.teads.sdk.combinedsdk.adplacement.interfaces.core.TeadsAdPlacement;
import java.util.Map;
public class BannerActivity extends AppCompatActivity implements TeadsAdPlacementEventsDelegate {
private TeadsAdPlacementBanner banner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 1. Build the placement configuration — this 4-arg constructor is a real
// Java-visible overload generated for the config's trailing default parameters
TeadsAdPlacementBannerConfig config = new TeadsAdPlacementBannerConfig(
Uri.parse("https://yoursite.com/article"),
"MB_10", // Provided by your Teads account manager
"YOUR_INSTALLATION_KEY",
0
);
// 2. Create the placement and load the ad — context (this) MUST be an Activity
TeadsAdPlacementBanner placement = new TeadsAdPlacementBanner(this, config, this);
banner = placement;
// 3. Attach the returned view to your container
FrameLayout adView = placement.loadAd();
((FrameLayout) findViewById(R.id.banner_container)).addView(adView);
}
@Override
public void onPlacementEvent(TeadsAdPlacement<?, ?> placement, TeadsAdPlacementEventName event, Map<String, ?> data) {
// React to placement lifecycle events — see Placement Events Listener for the full event reference.
}
}
Best Practices
Use an Activity context to create TeadsAdPlacementBanner (not the application context). The SDK uses it to size the creative correctly. Passing the application context can cause the ad to be mis-sized.
Keep the host container's height as wrap_content. A fixed height clips the ad because the JS engine resizes the view dynamically as the creative loads.
The SDK opens the paid CLICKED URL. Do not navigate in that handler or the browser will open twice. Use it for tracking only. CLICKED_ORGANIC is publisher-owned — you still open that URL yourself.
Ad Lifecycle Listener
Implement TeadsAdPlacementEventsDelegate to observe playback, clicks, and viewability. See Placement Events Listener for the full event reference and error handling guide.
Checklist
- ✅ Ensure Brand Safety is enabled
- ✅ Ensure you comply with privacy legal requirements (GDPR/CCPA/GPP)
- ✅ Comply with app-ads.txt
- ✅ Implement proper error handling
- ✅ Test with the PIDs in Test PIDs and Configurations