SelfRenderingNative - Atmosplay/AtmosplayAds-Android Wiki

Integrate Self Rendering Native Ad

Self rendering is another rendering mode, which has high flexibility, of native ad. You can splice ad style according to your needs to make ad more suitable for your app.

Initialize Native Ad

AtmosplayNativeAd mAtmosplayNativeAd = new AtmosplayNativeAd(mContext, mAppId, mAdUnitId)

Add NativeRender to Set Layout of Ad

Following elements are included in custom layout:

- mainImageId: id that used to display ImageView of ad's main image
- iconImageId: id that used to display iconImageView of ad's icon
- titleId: id that used to display TextView of ad's title
- textId: id that used to display TextView of ad's description
- buttonId: id that used to display "INSTALL NOW" Button
- playerId: id that used to play VideoView of ad's video
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.native_ad_layout)
NativeAdRender nativeAdRender = new NativeAdRender(viewBinder);

Attention: NativeAdRender must be set in self rendering mode. Otherwise, ad can not be displayed properly.

Add Listener

Add Request Listener Method and Creat Ad's View

 mAtmosplayNativeAd.setNativeAdLoadListener(new NativeAdLoadListener() {
    public void onNativeAdLoaded(NativeAd nativeAd) {
        // When request succeeded, creat ad View. mNativeView is parent container of ad View (like LinearLayout in Demo)
        View view = nativeAd.createAdView(YourActivity.this, mNativeView);

    public void onNativeAdFailed(int errorCode, String message) {
        // When failed to request ad, check "State Code and Description" section of this doc according to errorCode to locate problem quickly

Add Impression Listener Method (Optional)

If necessery, you can add listener callback of ad's impression/click as follows:

mNativeView.setNativeEventListener(new NativeEventListener() {
    public void onAdImpressed(View view) {
        // Ad has been impressed

    public void onAdClicked(View view) {
        // Ad has been clicked

Request Ad


The NativeAdSample file is the sample code of native ad(Self Rendering).