Android Setup Guide
This HyprMX SDK is designed to present Fullscreen (Interstitial and Rewarded) and Banner advertisements in your application.

Integrating the SDK

The following section details how to use the Android HyprMX SDK. This guide assumes you already have your Gradle-based project up and running in Android Studio.
1. Open your existing application in Android Studio.
2. Add the following repo to your top-level build.gradle dependencies:
1
allprojects {
2
repositories {
3
maven { url "https://hyprmx.jfrog.io/artifactory/hyprmx" }
4
}
5
}
Copied!
3. Add the HyprMX SDK to your app's build.gradle file dependencies block:
1
dependencies {
2
implementation 'com.hyprmx.android:HyprMX-SDK:6.0.1'
3
}
Copied!
4. Add Google Play Services Ads Identifier (recommended) to your app's build.gradle file dependencies block:
1
dependencies {
2
implementation 'com.google.android.gms:play-services-ads-identifier:17.1.0'
3
}
Copied!
5. If you are using Kotlin in your application, add the following to your build.gradle inside the android block:
1
kotlinOptions {
2
jvmTarget = "1.8"
3
freeCompilerArgs = [
4
"-Xjvm-default=compatibility",
5
]
6
}
Copied!

AndroidManifest

Permissions

In order to maximize fill rates, we recommend adding the following permissions:
1
<uses-permission android:name="android.permission.VIBRATE" />
Copied!

Usage

Initialization

First, add the following imports to your activity:
Java
Kotlin
1
import com.hyprmx.android.sdk.core.HyprMX;
2
import com.hyprmx.android.sdk.core.HyprMXIf;
3
import com.hyprmx.android.sdk.core.HyprMXErrors;
4
import com.hyprmx.android.sdk.core.HyprMXState;
5
import com.hyprmx.android.sdk.placement.Placement;
6
import com.hyprmx.android.sdk.placement.PlacementListener;
7
import com.hyprmx.android.sdk.placement.RewardedPlacementListener;
Copied!
1
import com.hyprmx.android.sdk.core.HyprMX
2
import com.hyprmx.android.sdk.core.HyprMXErrors
3
import com.hyprmx.android.sdk.core.HyprMXIf
4
import com.hyprmx.android.sdk.placement.Placement
5
import com.hyprmx.android.sdk.placement.PlacementListener
6
import com.hyprmx.android.sdk.placement.RewardedPlacementListener
Copied!
Initialize the HyprMX SDK in your main Activity inside the onCreate method as shown below. As a best practice, initialize HyprMX as soon as possible (i.e. when your application is loading) so we can begin preloading ads.
The initializer includes a consentStatus parameter for jurisdictions that require passing consent that takes a ConsentStatus value (CONSENT_STATUS_UNKNOWN, CONSENT_GIVEN, or CONSENT_DECLINED) depending on the user consent collected by your app.
Java
Kotlin
1
String distributorID = "Your Distributor ID";
2
String userID = "Your User's ID";
3
ConsentStatus consentStatus = ConsentStatus.CONSENT_STATUS_UNKNOWN; // If you don't have consent status for the user, set this to CONSENT_STATUS_UNKNOWN
4
HyprMXIf.HyprMXInitializationListener initializationListener;
5
HyprMX.INSTANCE.initialize(this, distributorID, userID, consentStatus, initializationListener);
Copied!
1
val distributorID = "Your Distributor ID"
2
val userID = "Your User ID"
3
var CONSENT_STATUS = ConsentStatus.CONSENT_STATUS_UNKNOWN
Copied!
The value for distributorID is assigned to your app by HyprMX. If you have not received this ID and your placements information, please reach out to your HyprMX account manager.
The userID is a unique identifier supplied by your application and must be static for each user across sessions. Your userID should not contain any personally identifiable information such as an email address, screen name, Android ID (AID), or Google Advertising ID (GAID). If you don’t already have a static user identifier, you can use the code below to generate one.
Java
Kotlin
1
private String getUserId() {
2
SharedPreferences sharedPreferences = getSharedPreferences("hyprmx_prefs", Context.MODE_PRIVATE);
3
String userID = sharedPreferences.getString("hyprUserId", null);
4
if (userID == null) {
5
userID = UUID.randomUUID().toString();
6
sharedPreferences.edit().putString("hyprUserId", userID).apply();
7
}
8
return userID;
9
}
Copied!
1
private fun getUserId(): String {
2
val sharedPreferences = getSharedPreferences("hyprmx_prefs", Context.MODE_PRIVATE)
3
var userID = sharedPreferences.getString("hyprUserId", null)
4
if (userID == null) {
5
userID = UUID.randomUUID().toString()
6
sharedPreferences.edit().putString("hyprUserId", userID).apply()
7
}
8
return userID
9
}
Copied!
HyprMX also provides a separate setter for consent status. Use this when a user's consent status changes:
Java
Kotlin
1
HyprMX.INSTANCE.setConsentStatus(consentStatus);
Copied!
1
HyprMX.setConsentStatus(ConsentStatus.CONSENT_STATUS_UNKNOWN)
Copied!

initializationListener

initializationListener is the listener for Initialization Status of the SDK. It will callback to initializationComplete or initializationFailed as below:
Java
Kotlin
1
HyprMXIf.HyprMXInitializationListener initializationListener = new HyprMXIf.HyprMXInitializationListener() {
2
@Override
3
public void initializationComplete() {}
4
5
@Override
6
public void initializationFailed() {}
7
};
Copied!
1
val initializationListener = object : HyprMXIf.HyprMXInitializationListener {
2
override fun initializationComplete() {}
3
override fun initializationFailed() {}
4
}
Copied!
After receiving the initializationDidComplete callback, you are now ready to load and display ads in your application. See our Rewarded Ads, Interstitial Ads, and Banner Ads guides to add these ad types to your app.

License

By integrating the HyprMX SDK, you are agreeing to the End User License Agreement.
Last modified 1mo ago