...
Next, add a listener - the listener will allow you to receive events from the ad unit. The pull-tab thumbnail ad has some additional callbacks for pull-tab thumbnail specific events.
Code Block | ||
---|---|---|
| ||
pullTabthumbnailAd.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 } } }); |
...
Anchor | ||||
---|---|---|---|---|
|
Once the pull-tab thumbnail ad has triggered the onAdLoaded
callback, you can then call showAd()
to start displaying the initial thumbnail state of the ad:
...