For the complete documentation index, see llms.txt. This page is also available as Markdown.

🎨Collapsible Anchored Adaptive Banner Ad (Only for GAM)

Below are the steps to request a collapsible anchored adaptive banner ad.

  1. Create your AdRequestConfiguration as per the below format

AdRequestConfiguration.Builder configuration = AdRequestConfiguration.Companion.builder(context, "Your_placement_name");
  1. Adding anchored adaptive ad type to AdRequest.

configuration.addAnchoredAdaptiveBannerAdSize(300, CollapsiblePlacement.BOTTOM);

The collapsible placement defines how the expanded region anchors to the banner ad.

Placement value
Behavior
Intended use case

TOP

The top of the expanded ad aligns to the top of the collapsed ad.

The ad is placed at the top of the screen.

BOTTOM

The bottom of the expanded ad aligns to the bottom of the collapsed ad.

The ad is placed at the bottom of the screen.

  1. Call loadAd() method as per below format

AdSterAdLoader.Companion.builder().withAdsListener(new MediationAdListener() {
    @Override
    public void onBannerAdLoaded(@NonNull MediationBannerAd ad) {
        super.onBannerAdLoaded(ad);
        // Show banner ad here
    }

    @Override
    public void onFailure(@NonNull AdError adError) {
        // Handle failure here
    }
}).withAdsEventsListener(new AdEventsListener() {
    @Override
    public void onAdClicked() {
        //Handle ad click here
    }

    @Override
    public void onAdImpression() {
        //Handle ad impression here
    }
    
    @Override
    public void onAdRevenuePaid(double revenue, @NotNull String adUnitId, @NotNull String network, @NotNull String currency, @NotNull PrecisionType precisionType) {
        // Callback which provides revenue and the network which provided it
    }
}).build().loadAd(configuration.build());
  1. Inside the onBannerAdLoaded callback method invoke getView() method of MediationnBannerAd object to add an AdSter banner view to the given layout as shown below

  1. Call MediationBannerAd.destroy() When activity/fragment is destroyed or detached.

Last updated