Amazon 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 HyprMX SDK to your app's build.gradle file dependencies block:
1
dependencies {
2
implementation 'com.hyprmx.android:HyprMX-SDK:6.0.2'
3
}
Copied!
3. 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!

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.
The initializer includes an optional ageRestrictedUser parameter. If the user is under the age of 16, set this parameter to true.
Base Initializer (use if your app's target audience does not include children and consent API is not applicable):
Java
Kotlin
1
String distributorID = "Your Distributor ID";
2
String userID = "Your User's ID";
3
HyprMXIf.HyprMXInitializationListener initializationListener;
4
// Use this initializer if your app's target audience does not include children. ageRestrictedUser defaults to false. Consent defaults to UNKNOWN.
5
HyprMX.INSTANCE.initialize(this, distributorID, userID, initializationListener);
Copied!
1
val distributorID = "Your Distributor ID"
2
val userID = "Your User's ID"
3
val initializationListener: HyprMXIf.HyprMXInitializationListener = this
4
// Use this initializer if your app's target audience does not include children. ageRestrictedUser defaults to false. Consent defaults to UNKNOWN.
5
HyprMX.initialize(this, distributorID, userID, initializationListener)
Copied!
Initializer with Consent API (use if your app's target audience does not include children):
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 know consent status for the user, set this to CONSENT_STATUS_UNKNOWN
4
HyprMXIf.HyprMXInitializationListener initializationListener;
5
// Use this initializer if your app's target audience does not include children. ageRestrictedUser defaults to false.
6
HyprMX.INSTANCE.initialize(this, distributorID, userID, consentStatus, initializationListener);
Copied!
1
val distributorID = "Your Distributor ID"
2
val userID = "Your User's ID"
3
val consentStatus = ConsentStatus.CONSENT_STATUS_UNKNOWN // If you don't have consent status for the user, set this to CONSENT_STATUS_UNKNOWN
4
val initializationListener: HyprMXIf.HyprMXInitializationListener = this
5
// Use this initializer if your app's target audience does not include children. ageRestrictedUser defaults to false.
6
HyprMX.initialize(this, distributorID, userID, consentStatus, initializationListener)
Copied!
Initializer with Consent and AgeRestrictedUser API (use if your app's target audience includes children):
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
boolean ageRestrictedUser = true; // Set this to true if the user is under 16
6
// Use this initializer if your app's target audience includes children.
7
HyprMX.INSTANCE.initialize(this, distributorID, userID, consentStatus, ageRestrictedUser, initializationListener);
Copied!
1
val distributorID = "Your Distributor ID"
2
val userID = "Your User's ID"
3
val consentStatus = ConsentStatus.CONSENT_STATUS_UNKNOWN // If you don't have consent status for the user, set this to CONSENT_STATUS_UNKNOWN
4
val initializationListener: HyprMXIf.HyprMXInitializationListener = this
5
val ageRestrictedUser = true // Set this to true if the user is under 16
6
// Use this initializer if your app's target audience includes children.
7
HyprMX.initialize(this, distributorID, userID, consentStatus, ageRestrictedUser, initializationListener)
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