Introduction

This page will help you integrate the Media.net AD SDK to your project. You can reach us at mobileapps@media.net if you have any queries during integration.

There are 5 steps to the process:

  • Adding Repository
  • Adding Dependencies
  • Making changes to AndroidManifest and adding permissions
  • Editing of ProGuard settings
  • Ad views integration
    • Banner Ad (Banner Video Ads Included)
    • Interstitial Ad (Interstitial Video Ads Included)
    • Rewarded Video Ad

Requirements

Media.Net Ad SDK requires the app to have the following:

  • Android 2.3 (API Version 9) and above.

Note: Android Studio and Gradle

These instructions assume you are using Android Studio and Gradle. Most of the required AndroidManifest.XML entries (Except the Location permissions) and ProGuard changes are automatically added to your app. If you are using other build systems, the steps may vary.

Integration Steps

1. Adding Repository

Add a maven repo into your repositories block of main Gradle file:

   maven { url "http://medianet.bintray.com/maven" }

2. Adding Dependencies

Add the below dependencies to your build.gradle file.

   dependencies  {
     compile "net.media.android:base:1.2.5"
   }

3. Adding Permissions and Making Changes to Androidmanifest

The SDK technically only requires internet permissions. Most of the required AndroidManifest.XML entries and ProGuard changes are automatically added to your app.

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

If you are using interstitial ads in your app the following lines has to be added in the Android Manifest. This is not required for Banner Ads.

   <activity android:name="net.media.android.base.pub.activity.MNetActivity" />

4. Initialising the SDK

Initialize the Media.net SDK with the following code and customer ID in your app’s application class. Your 9-digit numeric customer ID could be obtained by contacting your Media.Net account manager.

   MNet.init(this, "XXXXXXXXX");

For Child-Directed content,

   MNet.init(this, "XXXXXXXXX", childDirectedContent);

Displaying Ads

Once you have completed the integration, you can start displaying ads in your application by following the simple instruction on the Banner Ad, Banner Video Ad](/integrating-banner-video-ads-android/), Interstitial Ad, Interstitial Video Ad and/or Rewarded Video Ad pages.

GDPR

This section will be a guide to pass GDPR (General Data Protection Regulation) consent details into MNetAdSdk.

You can use the following function to pass the consent details to the SDK.

/**
 * Function to be used to update GDPR concent with Media.Net SDK
 *
 * @param   subjectToGdpr      Integer representing the flag if GDPR is applicable for current user
 *                                              Possible values:  1 (GDPR Applicable to the user)
 *                                                                0 (Not Applicable)
 *                                                               -1 (Unknown)
 * @param consentStatus        Integer representing the status of consent for GDPR
 *                                              Possible values:  1 (Consent provided)
 *                                                                0 (Consent denied)
 *                                                               -1 (Consent not set)
 * @param consentString        String representing consent string
 */
public static void updateGdprConsent(int subjectToGdpr, int consentStatus, String consentString)

The example below illustrates the usage -

MNet.updateGdprConsent(1,1,"consent_string")