Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Thumbnail ads are a brand new ad unit type that gives our SDK publishers an entirely incremental revenue stream. Thumbnails are unobtrusive videos that float on top of your app content. You can customize where and when the thumbnail ad is displayed to ensure that it doesn’t negatively impact user experience or cover important UI controls.

2022-10-27 11-35-09.mp4

Prerequisites

  • Ensure that you have a Thumbnail Ad Placement ID to use

Display a Thumbnail ad in your app

Displaying a thumbnail ad is a two-step process. First you should create and load your MobileFuseThumbnailAd unit, then when you’re ready, call the showAd() method to display the ad.

  1. Create a thumbnail ad unit

  2. Display the ad

Create a Thumbnail ad unit

The MobileFuseThumbnailAd class provided by the MobileFuse SDK will handle the loading, display, and interactivity of the thumbnail. It is similar in implementation to MobileFuse interstitial ads.

First, create a new MobileFuseThumbnailAd unit and keep a reference to it within the Activity that you want to use it:

private MobileFuseThumbnailAd thumbnailAd;

private void createThumbnailAd() {
    String placementId = "000000";
    thumbnailAd = new MobileFuseThumbnailAd(this, placementId);
    // ...
}

Note: Ensure that the SDK has fully initialized before creating your ad units. You can use the onInitSuccess callback as a good place to set up your ad units.

Next, add a listener - the listener will allow you to receive events from the ad unit. The thumbnail ad has some additional callbacks for thumbnail specific events.

thumbnailAd.setListener(new MobileFuseThumbnailAd.Listener() {
    @Override
    public void onAdClosed() {
        // The thumbnail ad has been dismissed and closed
    }

    @Override
    public void onStateChange(@NonNull MobileFuseThumbnailAd.AdState newState) {
        if (newState == MobileFuseThumbnailAd.AdState.FULL_SCREEN) {
            // The thumbnail ad is now rendering in full-screen mode, you should
            // mute any audio/pause your app
        } else if (newState == MobileFuseThumbnailAd.AdState.THUMBNAIL) {
            // The thumbnail ad is now rendering as a floating thumbnail, your 
            // app should not be paused
        }
    }

    @Override
    public void onAdLoaded() {
        // Called when the ad has been loaded and is ready to be displayed
    }

    @Override
    public void onAdNotFilled() {
        // The server responded with no fill (no ad available)
    }

    @Override
    public void onAdRendered() {
        // The ad has been rendered and is displaying to the user
    }

    @Override
    public void onAdClicked() {
        // Called when the user clicks the ad
    }

    @Override
    public void onAdExpired() {
        // This ad has expired and can no longer be displayed to the user - load a new ad
    }

    @Override
    public void onAdError(AdError adError) {
        // An error occurred, examine the adError argument to determine the problem
    }
});


// You can also listen for mute/unmute events - these happen when the user manually un-mutes the ad
// and you should ensure that your app is not playing music at the same time:
ad.setMuteChangedListener(new MuteChangedListener() {
    @Override
    public void onMutedChanged(boolean muted) {
        if (muted) {
            // The ad is muted, your app can play audio as normal
        } else {
            // The ad is playing sound - mute any music that your app is playing
        }
    }
});

Finally, request that the ad is preloaded using the loadAd method:

thumbnailAd.loadAd();

Display the ad

Once the thumbnail ad has triggered the onAdLoaded callback, you can then call showAd() to start displaying the initial thumbnail state of the ad:

thumbnailAd.showAd();

Optionally, you can specify the corner for the ad to be displayed in - this will default to bottom-right:

// Choose where to display the ad!
thumbnailAd.showAd(MobileFuseThumbnailAd.Position.BOTTOM_LEFT);
thumbnailAd.showAd(MobileFuseThumbnailAd.Position.BOTTOM_RIGHT);
thumbnailAd.showAd(MobileFuseThumbnailAd.Position.TOP_LEFT);
thumbnailAd.showAd(MobileFuseThumbnailAd.Position.TOP_RIGHT);

You can also use isLoaded() to check whether the ad is ready to be displayed.

if (thumbnailAd.isLoaded()) {
   // The ad is ready to be displayed!
}
  • No labels