> For the complete documentation index, see [llms.txt](https://aatkit.gitbook.io/android-integration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aatkit.gitbook.io/android-integration/formats/native-ad/network-specifics/native-ads-facebookaudiencenetwork.md).

# Native Ads: FacebookAudienceNetwork

To use Facebook Audience Networks native ads you need to do the following:

* The views used for main image and icon need to be an instances of `com.facebook.ads.MediaView`.&#x20;

{% tabs %}
{% tab title="Java" %}

```java
private ViewGroup containerView;
private TextView titleView;
private TextView descriptionView;
private com.facebook.ads.MediaView mainImageView;
private com.facebook.ads.MediaView iconView;
private TextView advertiserView;
private TextView ctaView;

private void setupFacebookNativeAd(NativeAdData nativeAd) {
    // TODO: create the container view and subviews from layout file

    // Title
    titleView.setText(nativeAd.getTitle());

    // Body
    descriptionView.setText(nativeAd.getDescription());

    // Advertiser
    advertiserView.setText(nativeAd.getAdvertiser());

    // CallToAction
    ctaView.setText(nativeAd.getCallToAction());

    nativeAd.attachToLayout(containerView, mainImageView, iconView, ctaView);
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
private val containerView: ViewGroup? = null
private val titleView: TextView? = null
private val descriptionView: TextView? = null
private val mainImageView: com.facebook.ads.MediaView? = null
private val iconView: com.facebook.ads.MediaView? = null
private val advertiserView: TextView? = null
private val ctaView: TextView? = null

private fun setupFacebookNativeAd(nativeAd: NativeAdData) {
    // TODO: create the container view and subviews from layout file

    // Title
    titleView.text = nativeAd.title

    // Body
    descriptionView.text = nativeAd.description

    // Advertiser
    advertiserView.text = nativeAd.advertiser

    // CallToAction
    ctaView.text = nativeAd.callToAction
    nativeAd.attachToLayout(containerView!!, mainImageView, iconView, ctaView)
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
You do not have to fill the main image and icon views, that will be done by Facebook SDK.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aatkit.gitbook.io/android-integration/formats/native-ad/network-specifics/native-ads-facebookaudiencenetwork.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
