Native Ads: Bluestack
Integrate native ads (Bluestack)
To use Bluestack native ads you need to do the following:
Native ad assets are required to be encapsulated within a parent view of a specific type MAdvertiseNativeContainer.
The same view must be passed to AATKit via the NativeAdData
method: attachToLayout
.
The view used for main image needs to be an instance of ViewGroup
.
The view used for icon needs to an ImageView
.
private MAdvertiseNativeContainer containerView;
private TextView titleView;
private TextView descriptionView;
private ViewGroup mainImageView;
private ImageView iconView;
private TextView advertiserView;
private TextView ctaView;
private void setupBluestackAd(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);
}
private val containerView: MAdvertiseNativeContainer? = null
private val titleView: TextView? = null
private val descriptionView: TextView? = null
private val mainImageView: ViewGroup? = null
private val iconView: ImageView? = null
private val advertiserView: TextView? = null
private val ctaView: TextView? = null
private fun setupBluestackAd(nativeAd: NativeAdData) {
// 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)
}
You do not have to fill the main image and icon views, that will be done by Bluestack SDK.