AATKit Android Integration
Release Notes
  • Start
    • Setup
      • Maven
      • Prerequisites
      • Google Family Safe Apps
    • Initialization
    • Consent
      • General Handling
      • Managed Consent
        • Google CMP
        • Sourcepoint CMP
        • SFBX (AppConsent) CMP
      • Vendor Consent
      • Simple Consent
    • Plugins documentation
    • Additional Information
  • Formats
    • Introduction
    • Banner
      • Auto Load Banner
      • Multi-Size Auto Load Banner
      • Banner Cache
      • Infeed Banner
      • Sticky Banner
      • Multi-Size Banner
    • Fullscreen (Interstitial)
    • AppOpen (Google)
    • Rewarded Video
      • Server-Side Verification (SSV)
    • Native Ad
      • Basic Integration
      • Network Specifics
        • Native Ads: Google
        • Native Ads: ApplovinMax
        • Native Ads: Bluestack
        • Native Ads: FacebookAudienceNetwork
        • Native Ads: Huawei
  • Ad Networks
    • Customize Ad Networks
    • Google Mobile Ads SDK
    • AppLovinMax Ad Review
    • AppNexus special settings
    • FeedAd Shutter Colour and Disabling Spinner
    • Kidoz
  • Advanced
    • Targeting
      • Key-Value Targeting
      • User Targeting
      • Content Targeting URL
    • Frequency Capping
    • Advanced Listeners
      • Reports Delegate
      • Impression Listener (ILRD)
      • Statistics Listener
    • AATKit's Size
    • Ad Space and Fill Rate
    • Shake Debug
    • Child-directed Support
    • Geo Tracking
    • Disabling Ad Networks
    • Huawei Support
    • Creatives History
  • Other
    • AdMob Custom Events
    • Reference
      • Classes
        • AATKit
        • AATKitUserTargeting
        • CollapsibleBannerOptions
        • AATKitDebugScreenConfiguration
        • PlacementDebugInfo
        • AATKitDebugInfo
        • AATKitConfiguration
        • AATKitRuntimeConfiguration
        • ManagedConsent
        • VendorConsent
        • SimpleConsent
        • BannerConfiguration
        • BannerRequest
        • BannerCacheConfiguration
        • AATKitReward
        • NativeAdRating
        • AATKitImpression
        • PriceInfo
        • AdInfo
        • RewardedAdSSVInfo
        • PlacementHistoryInfo
        • AATKitAdNetworkOptions
          • SuperAwesomeOptions
          • FeedAdOptions
          • AppNexusOptions
          • AdMobOptions
          • DFPOptions
      • Interfaces
        • CacheStatusDelegate
        • AATKit.Delegate
        • BannerCache
        • BannerRequestCompletionListener
        • ManagedConsentDelegate
        • VendorConsentDelegate
        • Placement
        • StickyBannerPlacement
        • StickyBannerPlacementListener
        • MultiSizeBannerPlacement
        • MultiSizeBannerPlacementListener
        • InfeedBannerPlacement
        • InfeedBannerPlacementListener
        • BannerRequestDelegate
        • CacheDelegate
        • FullscreenPlacement
        • FullscreenPlacementListener
        • AppOpenAdPlacement
        • AppOpenPlacementListener
        • RewardedVideoPlacement
        • RewardedVideoPlacementListener
        • NativeAdPlacement
        • NativePlacementListener
        • NativeAdData
        • AutoLoadBannerPlacement
        • AutoLoadBannerPlacementListener
        • AutoLoadMultiSizeBannerPlacement
        • AutoLoadMultiSizeBannerPlacementListener
        • ReportsDelegate
        • ImpressionListener
        • StatisticsListener
      • Enumerations
        • AATKitGender
        • AdNetwork
        • ManagedConsentState
        • NonIABConsent
        • BannerPlacementSize
        • BannerSize
        • MediationType
        • ImpressionPricePrecisionType
  • Samples
Powered by GitBook
On this page
  • Create Placement
  • Listen to Callbacks
  • Multi-Size Auto Load Banner Placement Listener
  • Request Ad
  • Complete Code Example
  1. Formats
  2. Banner

Multi-Size Auto Load Banner

Integrate Multi-Size Auto Load Banners

Last updated 10 months ago

Create Placement

Multi-size autoload banner placements are similar to , but can present banners of varying sizes. For instance, it is possible to display a banner of the standard size 320x53, followed by a medium rectangle of size 300x250 within the same placement.

It will depend on the server-side configuration on the Dashboard and what actual sizes are getting delivered to your placement.

To create an instance of , use the following API:

AutoLoadMultiSizeBannerPlacement placement = AATKit.createAutoLoadMultiSizeBannerPlacement("<PLACEMENT_NAME");
val placement = AATKit.createAutoLoadMultiSizeBannerPlacement("<PLACEMENT_NAME")

The green background is an ad container (FrameLayout), into which the placement view is added by the app. It represents the space that the app reserves for a multi-size banner placement view (the green colour is just used here for explanatory purposes).

Listen to Callbacks

placement.setListener(this);
placement.listener = this

Multi-Size Auto Load Banner Placement Listener

You will receive different placement callbacks by implementing the AutoLoadMultiSizeBannerPlacementListener.

@Override
public void onHaveAdWithBannerView(@NonNull Placement placement, @NonNull BannerPlacementLayout bannerView) {
    // The placement has loaded a new ad
    // [IMPORTANT] remove the previously displayed banner view
    // Add the received bannerView on the screen
}

@Override
public void onPauseForAd(@NonNull Placement placement) {
    // Ad went fullscreen and that application should pause.
}

@Override
public void onResumeAfterAd(@NonNull Placement placement) {
    // Ad came back from fullscreen and that application should resume.
}

@Override
public void onNoAd(@NonNull Placement placement) {
    // The placement could not load a new ad
}
override fun onHaveAdWithBannerView(placement: Placement, bannerView: BannerPlacementLayout) {
    // The placement has loaded a new ad
    // [IMPORTANT] remove the previously displayed banner view
    // Add the received bannerView on the screen
}

override fun onPauseForAd(placement: Placement) {
    // Ad went fullscreen and that application should pause.
}

override fun onResumeAfterAd(placement: Placement) {
    // Ad came back from fullscreen and that application should resume.
}

override fun onNoAd(placement: Placement) {
    // The placement could not load a new ad
}

Request Ad

Automatic Reload

To automatically load (and reload) the multi-size auto-load banner placement enable auto-reload. If you do not set the refresh time interval seconds explicitly, AATKit will

  • Reload every 30 seconds (if no refresh time interval is set on the Dashboard)

  • Respect the refresh time interval setting of the Dashboard (which means, you can configure the interval without having to re-publish your app)

// reload the banner placement every 30 seconds.
placement.startAutoReload();
// reload the banner placement every 30 seconds.
placement.startAutoReload()

The minimum refresh time is 30 seconds.

This needs to stop the auto-reload when it is no longer needed (e.g. if the view controller presenting ads will disappear):

placement.stopAutoReload();
placement.stopAutoReload()

One Placement for Multiple Screens

If the same placement is used on various different pages of the app and you want to load a new ad every time the user navigates to another page, you can achieve that by calling stopAutoReload() in the first controller and then call startAutoReload() in the next controller. This will immediately load and present a banner ad.

placement.stopAutoReload();
// move to next screen
placement.startAutoReload();
placement.stopAutoReload();
// move to next screen
placement.startAutoReload();

Complete Code Example

private AutoLoadMultiSizeBannerPlacement placement = AATKit.createAutoLoadMultiSizeBannerPlacement("<PLACEMENT_NAME");
private BannerPlacementLayout loadedBanner = null;

@Override
protected void onResume() {
    super.onResume();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityResume(this);

    // Set placement listener to listen to the callbacks
    placement.setListener(this);

    // reload the banner placement every 30 seconds.
    placement.startAutoReload();
}

@Override
protected void onPause() {
    // [IMPORTANT] Stop placement auto-reload
    placement.stopAutoReload();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityPause(this);
    super.onPause();
}

// AutoLoadMultiSizeBannerPlacementListener implementation
@Override
public void onPauseForAd(@NonNull Placement placement) {
    // App is paused after banner got clicked
}

@Override
public void onResumeAfterAd(@NonNull Placement placement) {
    // Back to the app after clicking on the ad
}

@Override
public void onHaveAdWithBannerView(@NonNull Placement placement, @NonNull BannerPlacementLayout bannerView) {
    //clear previous banner
    bannerFrame.removeAllViews();
    if (loadedBanner != null) {
        loadedBanner.destroy();
    }
    //present new banner
    loadedBanner = bannerView;
    bannerFrame.addView(loadedBanner);
}

@Override
public void onNoAd(@NonNull Placement placement) {
    // The placement could not load a new ad
}
private val placement = AATKit.createAutoLoadMultiSizeBannerPlacement("<PLACEMENT_NAME")
private var loadedBanner: BannerPlacementLayout? = null

protected override fun onResume() {
    super.onResume()
    // [IMPORTANT] Notify AATKit about activity lifecycle
    onActivityResume(this)

    // Set placement listener to listen to the callbacks
    placement.listener = this

    // reload the banner placement every 30 seconds.
    placement.startAutoReload()
}

protected override fun onPause() {
    // [IMPORTANT] Stop placement auto-reload
    placement.stopAutoReload()
    // [IMPORTANT] Notify AATKit about activity lifecycle
    onActivityPause(this)
    super.onPause()
}

// AutoLoadMultiSizeBannerPlacementListener implementation
fun onPauseForAd(placement: Placement) {
    // App is paused after banner got clicked
}

fun onResumeAfterAd(placement: Placement) {
    // Back to the app after clicking on the ad
}

fun onHaveAdWithBannerView(placement: Placement, bannerView: BannerPlacementLayout) {
    //clear previous banner
    bannerFrame.removeAllViews()
    loadedBanner?.destroy()
    //present new banner
    loadedBanner = bannerView
    bannerFrame.addView(loadedBanner)
}

fun onNoAd(placement: Placement) {
    // The placement could not load a new ad
}

Through the use of , you can listen to the different placement callbacks.

AutoLoadMultiSizeBannerPlacementListener
autoload banners
AutoLoadMultiSizeBannerPlacement