Integrating the SDK with your project

Last updated on April 12, 2019

The OpenX Mobile Android SDK provides integration scenarios for bannerThis is an ad that appears on a web page which is typically hyperlinked to an advertiser’s website. Banners can be images (GIF, JPEG, PNG), JavaScript programs or multimedia objects (For example, Java)., interstitialA full-screen ad displayed in content transitions. For example, a video ad that loads between levels of a mobile game., video interstitial, and opt-in videoA type of linear video ad or ad unit associated with mobile apps. A user opts into watching a full-screen, non-skippable video ad in exchange for a non-liquid, in-app reward after viewing the entire ad. Examples of rewards are: access to premium content or features, an extra life, continued play, a coupon, a discount code, or something else without monetary value. Opt-in video is also known as rewarded video and is not the same as incentivized video. ads. Before you start, you need to integrate the SDK by updating your Android manifest.

Updating your Android manifest

  1. Open your AndroidManifest.xml and add the following permissions and activity declarations according to the bundle you are integrating.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 


  2. For banner and interstitial ads only, include the following custom activities (even though you won’t instantiate them directly). This is not necessary for video interstitial ads.

    Custom Activities:

  3. Add this tag to your <application> to use Google Play Services:
     <meta-data android:name="" android:value="@integer/google_play_services_version" />  

Initializing the SDK for video pre-caching

The initialization of the SDK occurs dynamically when a user is about to view a video ad. As of OpenX Android SDK v4.9, you can enable initialization with video pre-caching, which causes an ad video to load on a device before the user views it. This alternative to streaming ensures that the video plays without delays for a better user experience.

Note: Video pre-caching requires the OpenX v4.9 Beta SDK. Contact your account manager if you want to be a test partner.

To enable pre-caching, you need to integrate video interstitial ads or opt-in video ads into your app. You also need to perform a separate initialization step, as in the following example:

// Create a container for initialization with custom options.
PreCacheAdConfiguration preCacheAdConfiguration = new PreCacheAdConfiguration();
ArrayList[AdConfiguration] preCacheAdConfigurations = new ArrayList[]();

// Initialize and configure AdConfiguration objects for preload
AdConfiguration preCacheConfiguration = new AdConfiguration();
preCacheConfiguration.domain = domain;
preCacheConfiguration.auid = auid;
preCacheConfiguration.adUnitIdentifierType = AdConfiguration.AdUnitIdentifierType.VAST;


// Set the configured preCacheList in created custom container for initialization
preCacheAdConfiguration.precachingAdConfigurations = preCacheAdConfigurations;

try {
	// Start SDK Initialization with custom options. 
	// OpenX SDK will initiate the loading of ads for provided vast tags immediately.
	OXSettings.initializeSDK(this, this, preCacheAdConfiguration);
catch (AdException e) {
	Log.w(this.getClass().getSimpleName(), e.getMessage());

Now you are ready to continue with specific integration steps for each ad type, or see the relevant adapter instructions:

Fill out my online form.