Native Ads: ApplovinMax
Integrate native ads (AppLovinMax)
To use Applovin’s native ads you need to do the following:
Native ad assets are required to be encapsulated within a parent view of a specific type MaxNativeAdView
.
The same view must be passed to AATKit via the NativeAdData
method: attachToLayout
.
Assign unique IDs to the native ad assets' Views in the layout file. These IDs will be used in the next integration step.
Bind the subviews using the assigned IDs using an instance of MaxNativeAdViewBinder
. AppLovin does not guarantee a network will return certain assets.
MaxNativeAdViewBinder maxNativeAdViewBinder;
maxNativeAdViewBinder = new MaxNativeAdViewBinder.Builder(R.layout.your_layout_for_applovinmax_native_ad)
.setTitleTextViewId( R.id.title_text_view )
.setBodyTextViewId( R.id.body_text_view )
.setAdvertiserTextViewId( R.id.advertiser_textView )
.setIconImageViewId( R.id.icon_image_view )
.setOptionsContentViewGroupId( R.id.options_view )
.setCallToActionButtonId( R.id.cta_button )
.build();
appLovinContainerView = new MaxNativeAdView(maxNativeAdViewBinder, activity);
val maxNativeAdViewBinder: MaxNativeAdViewBinder
maxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.your_layout_for_applovinmax_native_ad)
.setTitleTextViewId(R.id.title_text_view)
.setBodyTextViewId(R.id.body_text_view)
.setAdvertiserTextViewId(R.id.advertiser_textView)
.setIconImageViewId(R.id.icon_image_view)
.setOptionsContentViewGroupId(R.id.options_view)
.setCallToActionButtonId(R.id.cta_button)
.build()
appLovinContainerView = MaxNativeAdView(maxNativeAdViewBinder, activity)
Next, call attachToLayout
when you need to display the ad.
nativeAd.attachToLayout(appLovinContainerView, null, null, null);
nativeAd.attachToLayout(appLovinContainerView, null, null, null)