Show Native Ads on Android

Native ads give you the ability to create ads that are customized to match the look and feel of the rest of your application. This page describes our Native Ads API at a high level, and includes a usage example. For a complete reference, see the Javadoc.

Native networks supported through mediation:

Mopub

inMobi

Facebook

Yahoo Flurry

AdMob and DFP

In order to serve native ads, you will send a native ad request, and receive a native ad response. For Android 9 and above and API v. 28 and above, the request must be HTTPS by default in order to track viewability accurately. You can enable HTTPS with useHttps(true).

In the example code below, we:

Set up a request object and supply it with either:

The placement ID (as shown in the example code below), OR

A combination of inventory code and member ID:

Optionally, you can set the renderer_id for this NativeAdRequest. (For more on renderer_id see Native Layout Service.) The renderer_id needs to be specified in order for vastxml, likes, downloads, saleprice, phone, address, and display URL to be returned in the NativeAdResponse.

Register a listener that will signal native ad events such as clicks (NativeAdEventListener).

Register a listener to signal the state of the native request: success or failure. The listener must implement the NativeAdRequestListener interface.

If the request is successful (i.e., NativeAdListener.onAdLoaded() fires), native ad assets are loaded in the NativeAdResponse object which can be used in views that match the native look of the app. Then register the parent or container view of these views to enable impression and click tracking.

Unregister the native ad view after we're finished with it.

Maintain references to native views and native response objects

Maintain references to native views and native response objects.

It is your responsibility to keep a reference to the native ad view and NativeAdResponse object if necessary.

Fields Supported in Native

As of version 5.0 of the Mobile SDK, support for native assets is aligned with how native creatives are set up on Console.

If you are still using Legacy Native in Console, you will need to move to "New" Native for your creatives.

The following is a comprehensive list of native assets supported in the SDKs.