Android SDK Integration

Before You Start

We support Android Operating Systems Version 4.1 (API Level 16) and above. Be sure to:

  • Use Android Studio 3.0 and above

  • Target Android API level 28

  • minSdkVersion level 16 and above

Important! The ADAPTERS for ad networks are modularized as independent .aar files and should be downloaded as required by yourself. If you want to use OpenMediation SDK to mediate networks, Be sure to follow our Add Mediation Networks and Mediation Integration Guides.

NOTE: Starting from OpenMediation 2.3.1, we have adjusted the advertising APIs. For details, please refer to Android OM v2.3.1 API changes.


1. Overview

This Guideline introduces the integration of OpenMediation's SDK in Android Apps.

OpenMediation offers diversified and competent monetization services and supports a variety of Ad formats including Native Ad, Interstitial Ad, Banner Ad, and Rewarded Video Ad. The OpenMediation platform mediates AdTiming, AdMob, Facebook, UnityAds, Vungle, Tapjoy, AppLovin, AdColony, Chartboost, Helium, Pangle, TencentAds and ironSource.

New in Version 2.0 !

The OpenMediation SDK equipped with smart ad inventory mechanism and optimized SDK initialization pre-loading mechanism, provides the best mediation solution for app developers. For Rewarded Video, Interstitial and Interactive Ad, the SDK will cache ads automatically and maintain ad inventory regularly, such as pre-loading after initialization, loading after ad served and timing loading etc. You have no need to invoke load() method to cache ads by yourselves anymore. The new APIs are easier to use.


2. Ads ID

This section introduces how to fetch and use identity information when integrating the OpenMediation SDK, including: APP_KEY, Placement ID, account and configurations of the mediation platform.

APP_KEY: APP_KEY is the sole identification of developer’s application on OpenMediation platform. Developers need to create their Apps and obtain APP_KEY through the OpenMediation Developer Platform.

  • Navigate to Apps -> Select 'App Setting' -> Click on 'App Info'
  • Click on 'Copy' 

Placement ID: identifies the ads placement at OpenMediation. Developers may create multiple ads placement on the OpenMediation Developer Platform to meet their needs. The placement supports formats including BannerAd, InterstitialAd, NativeAd, VideoAd and PromotionAd.



3. Add OpenMediation SDK to your Project

Add the following to your project-level build.gradle file.

allprojects {
    repositories {
        maven { url '' }

Add the following to your application-level build.gradle file inside dependencies section.

implementation 'com.openmediation:om-android-sdk:+'


Cloned GitHub Repository

Alternatively, you can obtain the OpenMediation SDK source and Sample App form the GitHub Repository:

git clone git://


4. Update AndroidManifest.xml

... <uses-permission android:name="" />


5. Proguard

You must add the following to your Proguard configuration file (Android Studio: or Eclipse: proguard-project.txt) if you are using Porguard in your application. Failed to do so will lead to errors.

-dontwarn com.openmediation.sdk.**.*
-keep class com.openmediation.sdk.**{*;}


6. Override Your Activity Lifecycle Methods

Override the onPause()onResume() methods in each of your activities to call the corresponding OpenMediation methods as below:

protected void onResume() {
protected void onPause() {


7. Initialization

Before you can fetch ads from OpenMediation Platform, you should first initialize the OpenMediation SDK when your app started. To do so, we suggest to call OpenMediation SDK's init() method within onCreate() of an Application or Activity as below:

import com.openmediation.sdk.InitConfiguration;
import com.openmediation.sdk.OmAds;
import com.openmediation.sdk.InitCallback;
import com.openmediation.sdk.utils.error.Error;

InitConfiguration configuration = new InitConfiguration.Builder()
          .appKey("Your AppKey")
OmAds.init(configuration, new InitCallback() {

    // Invoked when the initialization is successful.
    public void onSuccess() {

    // Invoked when the initialization is failed.
    public void onError(Error message) {


  • APP KEY can only be obtained by creating apps on OpenMediation.
  • We suggest that the first call to method loadAd after the app starts should be in the onSuccess callback.
  • No need to invoke loadAd method for Rewarded Video & Interstitial Ads anymore, the SDK will fetch Ads automatic and maintain the ad inventory.
  • The error parameter in onError callback describes the cause of failure. Check the  Error Code for more information and guidance on errors. 

Best Practice: Init the SDK with AdUnits

The SDK can be initialized in another way and we recommend this approach as it will only fetch the specific ad units you define in the adUnits parameter. The adUnits parameter is a string array. The following illustrates that the SDK is initiated with Rewarded_Video&Interstitial AdUnits and only these two types Ads will be fetched automatic. 

// Ad Units should be in the type of OmAds.AD_TYPE.AdUnitName, for example:
InitConfiguration configuration = new InitConfiguration.Builder()
    .appKey("Your AppKey")
OmAds.init(configuration, callback);

When using this init approach, you can initialize each ad unit separately at different touchpoints in your app flow in one session.

// Init with pre-load Rewarded video ads
InitConfiguration configuration = new InitConfiguration.Builder()
    .appKey("Your AppKey")
OmAds.init(configuration, callback);
// Init with pre-load Interstitial ads
InitConfiguration configuration = new InitConfiguration.Builder()
    .appKey("Your AppKey")
OmAds.init(configuration, callback);
  • If no parameters are passed in the type, it means that the Rewarded Video and Interstitial ad types will be preloaded by default
  • If you don’t want to do any preloading, please pass in the OmAds.AD_TYPE.NONE parameter
// Init with no pre-load
InitConfiguration configuration = new InitConfiguration.Builder()
    .appKey("Your AppKey")
OmAds.init(configuration, callback);


  • AD_Units such as Native and Banner Ad have no need to initiate separately.

 Implement the Callback

The OpenMediation SDK fires several events to inform you of your initialing SDK operation. To receive these events, register to the callback in the init() and implement the onSuccess() and onError() of it.

public void onSuccess() {
    // Add code here to process init success event.
public void onError(Error error) {
    // Add code here to process init failed event.
    // Parameter message tells the error information.


  • The error parameter in onError callback describes the cause of failure. Check the Error Code for more information and guidance on errors.   

Report Custom User Identifier

The APP can report the customized device identifier through the SDK, and only needs to call the setUserId method to set it before initialization. This identifier will be reflected in user-level data, such as UAR report.

OmAds.setUserId(String userId);

Send attribution data to OpenMediation(optional)

If your project also integrates the AppsFlyer SDK, we need you to pass the application attribution data to OpenMediation so that we can help you accurately calculate each Media Source, Campaign level ROAS, and LTV data.

1. When you receive the onConversionDataSuccess callback you can use the sendAFConversionData method for passing the attribution data dictionary:

For apps using AppsFlyer SDK version 5 and above 

public void onConversionDataSuccess(Map<String, Object> conversionData) {
OmAds.sendAFConversionData(conversionData); }

For apps using AppsFlyer SDK version 4 and below

public void onInstallConversionDataLoaded(Map<String, String> map) { {
OmAds.sendAFConversionData(map); }

2. When you receive the onAppOpenAttribution callback you can use the sendAFDeepLinkData method for passing the attribution data dictionary:

public void onAppOpenAttribution(Map<String, String> conversionData) {
OmAds.sendAFDeepLinkData(conversionData); }


8. Use the TestSuite to test the integration (Optional)

  • Add the following dependencies to your app's build.gradle file inside dependencies section:
implementation 'com.openmediation:test-suite:+'
  • Use the following line of code to launch the Mediation Test Suite:
import com.openmediation.testsuite.TestSuite;
TestSuite.launch(activity, appKey);

You can get more help through the Test Suite Tool chapter.


What’s Next?

1. Integrate our Rewarded Video, Interstitial, Banner, Native , and Cross Promotion Ads in your app.
2. Follow 
our Add Mediation Networks and Mediation Network Guides to mediation networks.
3. After completing the above integration work, you can use Test Suite Tool to check whether the SDK aggregation integration is correct

Note: With the OpenMediation SDK, you need to download and add NOT ONLY the SDK of mediation networks you choose to work with BUT ALSO the adapters for those networks.

Was this article helpful?
11 out of 18 found this helpful



Article is closed for comments.