The following sections show you how to load and then show and hide a banner or MREC ad.
Loading a Banner or MREC
The following code shows you how to load a banner or MREC by using your Ad Unit ID, desired position, and (for banners) desired background color.
MAX will size the ad for you automatically:
You can preload ads for platform widgets before you mount MaxAdView.
When you mount MaxAdView with the Ad Unit ID you preloaded, MaxAdView is constructed with the preloaded platform widget.
This allows the ads to display quickly.
When you unmount MaxAdView, the preloaded platform widget is not destroyed.
Instead, it is reused for the next mount.
You must manually destroy it when it is no longer needed:
Adaptive banners are responsive banners with heights that derive from the device type and the width of the banner.
To disable adaptive banners, set the adaptive_banner flag like this:
Call AppLovinMAX.getAdaptiveBannerHeightForWidth(«width») to get the banner height, and then adjust your content accordingly.
Stopping and Starting Auto-Refresh
You may want to stop auto-refresh for an ad.
This may be the case when you hide an ad or when you want to manually refresh.
Stop auto-refresh with the following code: