Android Ad Formats

Banner Interstitial Rewarded Medium Rectangle

Banner Ads

After creating placements in the DT Console, add the following code snippets in the chosen context of your app. Access the Placement ID by using the copy button next to the placement name. For more information about creating placements in the DT Console, read here.

Screen

Banners are rectangle ads appearing either at the top or bottom of the screen when the user interacts with your app. The user can view banners but cannot dismiss them. Banners are automatically refreshed by the DT FairBid SDK after 20 seconds.

The DT FairBid SDK refreshes banners automatically. To avoid discrepancies between DT and 3rd-party network reporting, disable any automatic or manual banner refresh settings on 3rd-party network SDKs.

Showing a Banner

Implement the code below to show a Banner:

Kotlin
val placementId = "12345"
Banner.show(placementId, activity)

Java
String placementId = "12345";
Banner.show(placementId, activity);

Hiding the Banner

If you want to hide the banner temporarily, implement the code below:

Kotlin
//hides the banner for a specific placement
val placementId = "12345"
Banner.hide(placementId)

Java
//hides the banner for a specific placement
String placementId = "12345";
Banner.hide(placementId);

Destroying the Banner

Once you have decided that you no longer want to use the banner, you must destroy it.

To destroy the banner, implement the code below:

Kotlin
//destroys the banner for a specific placement
val placementId = "12345"
Banner.destroy(placementId)
Java
//destroys the banner for a specific placement
String placementId = "12345";
Banner.destroy(placementId);

Banner Position

By default, the banners are placed at the bottom of your screen.

You can place them at the top by using the code below:

Top Position

Kotlin
val bannerOptions = BannerOptions().placeAtTheTop()
val placementId = "12345"
Banner.show(placementId, bannerOptions, activity)
Java
BannerOptions bannerOptions = new BannerOptions().placeAtTheTop();
String placementId = "12345";
Banner.show(placementId, bannerOptions, activity);

Or you can provide your custom view and place them in there:

Kotlin
val bannerOptions = BannerOptions().placeInContainer(viewGroup)
val placementId = "12345"
Banner.show(placementId, bannerOptions, activity)
Java
BannerOptions bannerOptions = new BannerOptions().placeInContainer(viewGroup);
String placementId = "12345";
Banner.show(placementId, bannerOptions, activity);

 

Loading a Banner

Important

Use this implementation only if FairBid is not your main mediation platform, as this method disables banner refresh. So, you'll need to add your own refresh logic. 

You can pre-load a banner to review its pricing and other details if you want to use FairBid with other mediations or demand sources. This allows you to compare it against banners from other demand sources outside our platform before showing it.

To load a banner, create an instance of the BannerView object and then call the load method. Please be aware that this integration method disables banner refresh, and you must add your own refresh logic.

This is supported starting FairBid Android SDK 3.51.0.

Kotlin
val bannerContainer: FrameLayout
val placementId = "12345"

val bannerView = BannerView(requireContext(), placementId)
banner.bannerListener = object : BannerListener {
  //...
}
bannerView.load()

//Once the ad is loaded and ready, you can check the pre-impression data
val impressionData = bannerView.impressionData

// To show the banner, attach the bannerView to the Banner Container
bannerContainer.addView(bannerView)

//Once the banner is no longer needed, you can destroy it
bannerView.destroy()
          

 

Adaptive Banners

By enabling the adaptive banner feature, you can receive the best banner size based on the ad width and screen size. This feature is currently supported by Google AdMob, Google Bidding, and Google Ad Manager only. This feature is disabled by default.

Networks that support adaptive banners will return ads with the best-fit height based on your banner size. Other networks will continue to deliver banners according to the specified ad size.

To use this feature, add the "adaptive" flag when defining your banner size using the code below:

Kotlin
val bannerOptions = BannerOptions().setAdaptive(true)
val placementId = "12345"
Banner.show(placementId, bannerOptions, activity)
Java
BannerOptions bannerOptions = new BannerOptions().setAdaptive(true);
String placementId = "12345";
Banner.show(placementId, bannerOptions, activity);

 

Adding Callbacks

The callback code below is required for the SDK to properly track the activity of your ad.

Kotlin
Banner.setBannerListener(object : BannerListener {
    override fun onError(placementId: String, error: BannerError) {
        // Called when an error arises when showing the banner from placement 'placementId'
    }

    override fun onLoad(placementId: String) {
        // Called when the banner from placement 'placementId' is successfully loaded
    }

    override fun onShow(placementId: String, impressionData: ImpressionData) {
        // Called when the banner from placement 'placementId' is shown
    }

    override fun onClick(placementId: String) {
        // Called when the banner from placement 'placementId' is clicked
    }

    override fun onRequestStart(placementId: String, requestId: String) {
        // Called when the banner from placement 'placementId' is going to be requested
        // 'requestId' identifies the request across the whole request/show flow
    }
})
Java
Banner.setBannerListener(new BannerListener() {
    @Override
    public void onError(String placementId, BannerError error) {
        // Called when an error arises when showing the banner from placement 'placementId'
    }
 
    @Override
    public void onLoad(String placementId) {
        // Called when the banner from placement 'placementId' is successfully loaded
    }
 
    @Override
    public void onShow(String placementId, ImpressionData impressionData) {
        // Called when the banner from placement 'placementId' is shown
    }
 
    @Override
    public void onClick(String placementId) {
        // Called when the banner from placement 'placementId' is clicked
    }
 
    @Override
    public void onRequestStart(String placementId, String requestId) {
        // Called when the banner from placement 'placementId' is going to be requested
// 'requestId' identifies the request across the whole request/show flow } });

Back to Top ⇧