Integration Guide

The Millennial Media Android Ad SDK provides functionality for monetizing your Android applications. With the SDK, you can easily integrate inline, interstitial, and native ads into your application.

Requirements

  • Android version 4.1 and up (API level 16+)
  • Google play services
  • Android Support Library v4 25.0.0+
  • Gradle based build system
  • Build environment with Java 7

Adding the SDK to your project

1. Add the following permissions and provider within the AndroidManifest.xml for the application.

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission-sdk-23 android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
<uses-permission android:name="android.permission.NFC"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

NOTE: Information about how location works with SDK 6, is available here

<provider
	android:name="com.millennialmedia.internal.utils.MediaContentProvider"
	android:authorities="${applicationId}.MediaContentProvider"
	android:grantUriPermissions="true"
	android:exported="false" />

NOTE: Publishers using Unity should replace ${applicationId} with their application’s package due to an issue in the Unity Manifest Merger regarding the ‘$’ character. For example, if your application package is com.aol.aolapp then the authorities attribute value should be com.aol.aolapp.MediaContentProvider.

2. Initialize the MM SDK.

MMSDK.initialize(Application application) must be called prior to any API calls into the MM SDK. This should be called within the onCreate method of your Application subclass. Calling this method anywhere else is not supported. The MMSDK.initialize(Activity activity) method introduced in SDK 6.0 has been deprecated and should no longer be used. Please see the sample app included in the SDK download for an example that includes error handling.

import com.millennialmedia.MMSDK;

MMSDK.initialize(this); // pass in a reference to your Application subclass instance

3. Set the AppInfo to be passed along on ad requests.

This is needed to set the site ID and can optionally be used to set COPPA restrictions for ads being served to the application.

import com.millennialmedia.AppInfo;

AppInfo appInfo = new AppInfo();

appInfo.setSiteId(<YOUR_SITE_ID>);

MMSDK.setAppInfo(appInfo);

4. Set the UserData to be passed along with all ad requests. (Optional)

User data can be updated at any time but generally if the user data does not change it is best set after MMSDK.initialize.

import com.millennialmedia.UserData;

UserData userData = new UserData().
	setAge(<age>).
	setChildren(<children>).
	setCountry(<country>).
	setDma(<dma>).
	setDob(<dob>).
	setEducation(<education>).
	setEthnicity(<ethnicity>).
	setGender(<gender>).
	setIncome(<income>).
	setKeywords(<keywords>).
	setMarital(<marital>).
	setPolitics(<politics>).
	setPostalCode(<postal-code>).
	setState(<state>);
MMSDK.setUserData(userData);

Additional Topics