Madex
  • Android SDK
    • Installing and configuring the SDK
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change Log
  • iOS SDK
    • Installing and configuring the SDK
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change Log
  • Unity Plugin
    • Installing and configuring the plugin
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change log
  • Cordova Plugin
    • Installation and configuration the plugin
    • Working with advertising
    • Change Log
  • Construct3 Addon
    • Addon installation and configuration
    • Installation and configuration of Madex mediation addon
    • Working with advertising
Powered by GitBook
On this page
  • Identifiers from personal account
  • Publisher identifier (publisher_id)
  • Ad unit identifier (placement_name)
  • Test identifiers
  • Advertising Formats
  • Fullscreen Banner (Interstitial)
  • Rewarded Video
  • Banner 320x50
  • SDK Methods
  • Using Multiple Ad Units
  • Tracking Ad Events
  1. Android SDK

Working with advertising

General principle of interaction with ad units.

PreviousInstalling and configuring the SDKNextUser Consent Screen

Last updated 5 days ago

Identifiers from personal account

Publisher identifier (publisher_id)

To initialize the SDK you will need the publisher identifier (publisher_id)

Your publisher_id is located in the "Settings" section of your Madex personal account.

Ad unit identifier (placement_name)

When using SDK methods, you will need the ad unit identifier (placement_name) of the ad unit.

placement_name is the ID of the ad unit. Ad units are created in Madex personal account.

Test identifiers

During SDK integration, we recommend using special publisher_id and placement_name to get stable test ads.

Publisher ID - d42994c6-2145-4269-9c2f-2adcf9d9703f

International format

Madex Interstitial ID - 50f37030-162d-4e8c-a9c0-e078d8fbf2f7

IronSource Interstitial ID - 82e3bba6-6add-4594-8bb7-f96fef5b252d

Rewarded Video Format

Madex Rewarded ID - dacd566d-8487-4bc6-8afc-486f625be870

IronSource Rewarded ID - 42e716e1-91c0-47e0-9832-c36ada6fa836

Banner Format

Madex Banner ID - 901a609e-b9b2-4f82-b8b8-c899c5524867

Advertising Formats

The Madex advertising network supports 2 ad formats.

Fullscreen Banner (Interstitial)

The ad is displayed on the entire screen and contains a banner, interactive banner, or video. Tapping on it leads to a transition to the link specified by the advertiser.

Users can close the banner after 3 seconds.

This format is typically used when launching the application or transitioning between application screens.

When working with this format, use the Madex.INTERSTITIAL parameter.

Here's an example method call to display this format of advertising.

Madex.showAd(this, Madex.INTERSTITIAL, "placement_name");

Rewarded Video

The ad is displayed on the entire screen and contains a video or interactive banner. Tapping on it leads to a transition to the link specified by the advertiser.

Users can stop viewing the ad, but in this case, they will see a dialog warning about the lack of a reward when closing the video before its completion.

When working with this format, use the Madex.REWARDED parameter.

Here's an example method call to display this format of advertising.

Madex.showAd(this, Madex.REWARDED, "placement_name");

To determine whether to reward the user, use the onRewardedFinished event.

Banner 320x50

The ad is displayed at the bottom of the screen and contains an interactive banner. Tapping on it leads to a transition to the link specified by the advertiser.

When working with this format, use the Madex.BANNER parameter.

Here's an example method call to display this format of advertising.

Madex.showAd(this, Madex.BANNER, "placement_name");

Auto-Refresh of Banner Ads

To increase your profits, we have developed a function for automatic content change in the banner.

To configure, specify the interval in seconds (minimum 10 seconds).

If the parameter is not filled in or equals zero, the content will not be updated.

final BannerSettings settings = BannerSettings.builder()
        .setRefreshIntervalSeconds(10)
        .build();

Banner Placement By default, the banner is positioned at the bottom of the screen, but you can override this behavior in several ways.

Define the banner’s position using BannerSettings.

Bottom of the screen:

final BannerSettings settings = BannerSettings.builder()
        .setBannerPosition(BannerPosition.BOTTOM)
        .build();

Top of the screen:

final BannerSettings settings = BannerSettings.builder()
        .setBannerPosition(BannerPosition.TOP)
        .build();

When you declare BannerView in your layout XML, the ad will display immediately after loading—no need to call showAd().

Add the following to your layout file:

<sspnet.tech.core.BannerView
    android:id="@+id/banner_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent" />

Then pass that android:id into your banner settings:

final BannerSettings settings = new BannerSettings.Builder()
        .setBannerLayoutID(R.id.banner_view)
        .build();
Madex.setBannerCustomSettings(settings);

After the banner loads, add the following code:

final BannerView bannerView = Madex.getBannerView(placementName);
final FrameLayout.LayoutParams params = 
        (FrameLayout.LayoutParams) bannerView.getLayoutParams();

// To position at the bottom of the screen:
// params.gravity = Gravity.BOTTOM;

// To position at the top of the screen:
// params.gravity = Gravity.TOP;

addContentView(bannerView, params);

Show close button

By default, the close banner button is not shown, but you can enable it:

final BannerSettings settings =  new BannerSettings.Builder()
       .setShowCloseButton(true)
       .build();
Madex.setBannerCustomSettings(settings);

SDK Methods

Working with ads involves working with Madex SDK methods.

  1. initialize (required): Initializes the SDK. It's sufficient to call this method once at the application launch or before the first call to the loadAd method.

Madex.initialize("publisher_id");

  1. loadAd (required): Loads ads from the server. Usually, this method is called in advance so that the content is loaded by the time of the ad display. In this case, the user's waiting time for ad display will be minimal.

// Load Interstitial ad
Madex.loadAd(this, Madex.INTERSTITIAL, "placement_name");
// Load Rewarded video ad
Madex.loadAd(this, Madex.REWARDED, "placement_name");
// Load Banner ad
Madex.loadAd(this, Madex.BANNER, "placement_name");

  1. isAdLoaded (optional): Checks the ad unit loading status.

Madex.isAdLoaded(Madex.INTERSTITIAL, "placement_name");
Madex.isAdLoaded(Madex.REWARDED, "placement_name");
Madex.isAdLoaded(Madex.BANNER, "placement_name");

The method returns true or false. If the answer is negative, attempting to show the ad will lead to nothing.

Although the use of this method is optional, we strongly recommend checking the ad loading status before attempting to display it.

// Check the loading status and subsequently show the Interstitial ad
if (Madex.isAdLoaded(Madex.INTERSTITIAL, "placement_name")) {    
    Madex.showAd(this, Madex.INTERSTITIAL, "placement_name");
}

  1. showAd (required): Calls ad display using the player built into the SDK.

Madex.showAd(this, Madex.INTERSTITIAL, "placement_name");
Madex.showAd(this, Madex.REWARDED, "placement_name");
Madex.showAd(this, Madex.BANNER, "placement_name");

  1. destroyAd (optional): Destroys the ad container. You can work with multiple ad units simultaneously, but we strongly recommend destroying unnecessary ones to avoid memory issues and other problems.

// Destroy the Rewarded Video ad container
Madex.destroyAd(Madex.REWARDED, "placement_name");

Using Multiple Ad Units

You can work with multiple ad units asynchronously, meaning you can call methods with different placement_names and formats independently of each other. For example, you can call the loadAd method for several blocks at once and load them concurrently.

Tracking Ad Events

Madex SDK allows you to track events occurring with ads to use them for integrating ads into your application's logic.

To track events, you need to provide a class to work with.

Note that ad events work on any ad unit.

That is, if you call the loading of 2 ad units simultaneously, the loading event will work 2 times, once for each unit.

Here are examples of setting up existing ad events.

Madex.setInterstitialListener(new InterstitialListener(){
    @Override
    public void onInterstitialLoaded(AdPayload adPayload){
        // Called when the ad is loaded
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    @Override
    public void onInterstitialLoadFail(AdPayload adPayload, AdException error){
        // Called if there is an error loading the ad
        // Using AdPayload adPayload, you can get detailed information about the request
        // You can obtain detailed error information using AdException error
    }
    
    @Override
    public void onInterstitialShown(AdPayload adPayload){
        // Called when the ad is displayed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    @Override
    public void onInterstitialShowFailed(AdPayload adPayload, AdException error){
       // Called if there is an error displaying the ad
       // Using AdPayload adPayload, you can get detailed information about the request
       // You can obtain detailed error information using AdException error
    }
    
    @Override
    public void onInterstitialClosed(AdPayload adPayload){
        // Called when the ad is closed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
});
Madex.setRewardedListener(new RewardedListener(){
    @Override
    public void onRewardedLoaded(AdPayload adPayload){
        // Called when the ad is loaded
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    @Override
    public void onRewardedLoadFail(AdPayload adPayload, AdException error){
        // Called if there is an error loading the ad
        // Using AdPayload adPayload, you can get detailed information about the request
        // You can obtain detailed error information using AdException error
    }
    
    @Override
    public void onRewardedShown(AdPayload adPayload){
        // Called when the ad is displayed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    @Override
    public void onRewardedShowFailed(AdPayload adPayload, AdException error){
       // Called if there is an error displaying the ad
       // Using AdPayload adPayload, you can get detailed information about the request
       // You can obtain detailed error information using AdException error
    }
    
    @Override
    public void onRewardedClosed(AdPayload adPayload){
        // Called when the ad is closed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    @Override
    public void onRewardedVideoStarted(AdPayload adPayload){
        // Called when a video ad starts playing
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    @Override
    public void onRewardedVideoCompleted(AdPayload adPayload){
        // Called when the advertising video has completed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    @Override
    public void onUserRewarded(AdPayload adPayload){
        // Here you can reward the user
        // Using AdPayload adPayload, you can get detailed information about the request
    }
}
Madex.setBannerListener(new BannerListener(){
    @Override
    public void onBannerLoaded(AdPayload adPayload){
        // Called when the ad is loaded
        // Using AdPayload adPayload, you can get detailed information about the requeе
    }
    
    @Override
    public void onBannerLoadFailed(AdPayload adPayload, AdException error){
        // Called if there is an error loading the ad
        // Using AdPayload adPayload, you can get detailed information about the reque
        // You can obtain detailed error information using AdException error
    }
    
    @Override
    public void onBannerShown(AdPayload adPayload){
        // Called when the ad is displayed
        // Using AdPayload adPayload, you can get detailed information about the reque
    }
    
    @Override
    public void onBannerShowFailed(AdPayload adPayload, AdException error){
       // Called if there is an error displaying the ad
       // Using AdPayload adPayload, you can get detailed information about the reque
       // You can obtain detailed error information using AdException error
    }
    
    @Override
    public void onBannerClosed(AdPayload adPayload){
        // Called when the ad is closed
        // Using AdPayload adPayload, you can get detailed information about the reque
    }
    
    @Override
    public void onBannerImpression(AdPayload adPayload){
        // Recording the banner impression
        // Using AdPayload adPayload, you can get detailed information about the reque
    }
}

setUserConsent (optional): Intended for conveying the user's consent status for the collection, processing, and use of personal data. By default, it is set to false, meaning the user has not given consent to the use of their data for advertising and other purposes. We recommend using this method to improve ad monetization quality. You can obtain consent on your own or use our .

Consent Manager