Links

Android / Amazon Setup Guide

The HyprMX SDK is designed to present rewarded, interstitial, and banner ads in your application. To integrate the SDK, follow the steps below.

SDK Integration

You can integrate the HyprMX SDK through Gradle dependencies. Follow the steps below to set up the 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:
dependencies {
implementation 'com.hyprmx.android:HyprMX-SDK:6.2.3'
}
3. Adding Google Play Services Ads Identifier is optional. If the dependency below is included, it is the responsibility of the app developer to ensure compliance with all Google Play policies, including, and not limited to, Families Program.
dependencies {
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
}
4. If you are using Kotlin in your application, add the following to your build.gradle inside the android block:
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = [
"-Xjvm-default=compatibility",
]
}

Initializing HyprMX

After you have integrated the SDK, proceed to initializing the HyprMX SDK. To initialize, follow the steps below.
1. Add the following imports to your activity:
Java
Kotlin
import com.hyprmx.android.sdk.core.HyprMX;
import com.hyprmx.android.sdk.core.HyprMXIf;
import com.hyprmx.android.sdk.core.HyprMXErrors;
import com.hyprmx.android.sdk.core.HyprMXState;
import com.hyprmx.android.sdk.placement.Placement;
import com.hyprmx.android.sdk.placement.PlacementListener;
import com.hyprmx.android.sdk.placement.RewardedPlacementListener;
import com.hyprmx.android.sdk.core.HyprMX
import com.hyprmx.android.sdk.core.HyprMXErrors
import com.hyprmx.android.sdk.core.HyprMXIf
import com.hyprmx.android.sdk.placement.Placement
import com.hyprmx.android.sdk.placement.PlacementListener
import com.hyprmx.android.sdk.placement.RewardedPlacementListener
2. 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. Review the details of initialization parameters (distributorID, userID, consentStatus, and ageRestrictedUser) below to find out what initializer best suits your app's use case.

Sample Initializer

Java
Kotlin
String distributorID = "Your Distributor ID";
String userID = "Your User's ID";
ConsentStatus consentStatus = ConsentStatus.CONSENT_STATUS_UNKNOWN; // If you don't have consent status for the user, set this to CONSENT_STATUS_UNKNOWN
HyprMXIf.HyprMXInitializationListener initializationListener;
boolean ageRestrictedUser = true; // Set this to true if the user is under 16
// Use this initializer if your app's target audience includes children.
HyprMX.INSTANCE.initialize(this, distributorID, userID, consentStatus, ageRestrictedUser, initializationListener);
val distributorID = "Your Distributor ID"
val userID = "Your User's ID"
val consentStatus = ConsentStatus.CONSENT_STATUS_UNKNOWN // If you don't have consent status for the user, set this to CONSENT_STATUS_UNKNOWN
val initializationListener: HyprMXIf.HyprMXInitializationListener = this
val ageRestrictedUser = true // Set this to true if the user is under 16
// Use this initializer if your app's target audience includes children.
HyprMX.initialize(this, distributorID, userID, consentStatus, ageRestrictedUser, initializationListener)

distributorID (required)

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.

userID (required)

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 Device ID (AID), or Google Advertising ID/Android Advertising ID (GAID/AAID). If you don’t already have a static user identifier, you can use the code below to generate one.
Java
Kotlin
private String getUserId() {
SharedPreferences sharedPreferences = getSharedPreferences("hyprmx_prefs", Context.MODE_PRIVATE);
String userID = sharedPreferences.getString("hyprUserId", null);
if (userID == null) {
userID = UUID.randomUUID().toString();
sharedPreferences.edit().putString("hyprUserId", userID).apply();
}
return userID;
}
private fun getUserId(): String {
val sharedPreferences = getSharedPreferences("hyprmx_prefs", Context.MODE_PRIVATE)
var userID = sharedPreferences.getString("hyprUserId", null)
if (userID == null) {
userID = UUID.randomUUID().toString()
sharedPreferences.edit().putString("hyprUserId", userID).apply()
}
return userID
}

consentStatus (optional)

HyprMX provides an Initialization API with a consentStatus parameter with below values for jurisdictions that require passing consent that takes a ConsentStatus value depending on the user consent collected by your app. Refer to our privacy page for more information on consent flag.
  • CONSENT_STATUS_UNKNOWN
  • CONSENT_GIVEN
  • CONSENT_DECLINED
HyprMX also provides a separate method for setting Consent. Use this when a user's consent status changes:
Java
Kotlin
HyprMX.INSTANCE.setConsentStatus(consentStatus);
HyprMX.setConsentStatus(ConsentStatus.CONSENT_STATUS_UNKNOWN)

ageRestrictedUser (optional)

HyprMX provides an Initialization API with an ageRestrictedUser parameter. If the user requires child-directed treatment under applicable laws and policies, set this parameter to true. Otherwise, set it to false. For additional guidelines around this flag, please refer to our privacy page.

Initialization Callbacks

initializationListener is the listener for Initialization Status of the SDK. It will callback to initializationComplete or initializationFailed as below:
Java
Kotlin
HyprMXIf.HyprMXInitializationListener initializationListener = new HyprMXIf.HyprMXInitializationListener() {
@Override
public void initializationComplete() {}
@Override
public void initializationFailed() {}
};
val initializationListener = object : HyprMXIf.HyprMXInitializationListener {
override fun initializationComplete() {}
override fun initializationFailed() {}
}
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 2mo ago