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.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 inform buyers that the user is subject to Children’s Online Privacy Protection Act (COPPA) restrictions.

import com.millennialmedia.AppInfo;

AppInfo appInfo = new AppInfo();

appInfo.setSiteId(<YOUR SITE ID>);

MMSDK.setAppInfo(appInfo);

4. Set General Data Protection Regulation (GDPR) properties

In order to use the MM SDK to serve personalized advertising (based on information such as device advertising identifiers, location, and other personal data) to EU users, you need consent for the use of Oath ad products. Use setConsentRequired() to indicate if the user falls under GDPR jurisdiction. Use setConsentData() to set a consent string for the user. These values should be set after initialization and before requesting an ad. Consent information may be updated at anytime during the app’s execution should the user’s consent data or status change. Additional information can be found in the General Data Protection Regulation section.

// Set to true if the user falls under GDPR jurisdiction.
MMSDK.setConsentRequired(true); 

// Sets the IAB Consent String
MMSDK.setConsentData(IAB_CONSENT_KEY,<PUBLISHER-PROVIDED IAB CONSENT STRING>);  

5. 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.

Please note that the information set in this object will not be sent on ad requests for users under the jurisdiction of GDPR or similar future privacy regulations that have not consented to the use of their personal data for advertising purposes.

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