Gravite Plugin Documentation for Android

Gravite Plugin Documentation for Android

 

Gravite Plugin Integration Manual

Release Note (7.2.0)

  •  

 

Gravite Plugin for Android

If you wish to use Gravite, please contact your Ströer account manager for assistance.

Note: This feature is only available from Version 6.24.0 onwards.

 

1. Overview

This manual provides instructions for setting up Gravite within the YieldloveAdIntegration framework in your Android app.

2. Before you start

Please refer to this guide for detailed instructions. This manual specifically explains how to enable the Gravite feature.
Additionally, Gravite validates the bundle ID to provide its services. Ensure that your bundle ID is registered with Gravite before proceeding.

3. Example app

4. Add SDK dependencies to your project

Using Gradle:

Please include the following block in their build.gradle file:

repositories { maven { url ''https://slabs-yieldlove-ad-integration.s3.eu-central-1.amazonaws.com/android' } maven { url 'https://android-sdk.aatkit.com/maven/' } maven { url "https://s3.amazonaws.com/smaato-sdk-releases/" } //Smaato repository maven { url 'https://packagecloud.io/smartadserver/android/maven2' } // SmartAdServer repository maven { url 'https://verve.jfrog.io/artifactory/verve-gradle-release' } //PubNative repository maven { //ironSource repository url 'https://android-sdk.is.com/' } maven { //Ogury repository url 'https://maven.ogury.co' } maven { //GraviteRTB repository url 'https://android-sdk-rtb.gravite.net/maven' } maven { //Mintegral repository url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" } }

 

Use our libraries as dependencies:

dependencies { implementation 'com.intentsoftware.addapptr:AATKit:3.13.6' implementation 'com.yieldlove.adIntegration:gravite:7.2.2' implementation 'com.yieldlove.adIntegration:yieldlove:7.2.2' }

You may use a different version of the GraviteSDK, but only the version is officially supported.

5. Implementation

5.1. Setup

Initialize Gravite

To get started with Gravite, you need to initialize it properly.

// Initialize Gravite with the application context // Provide a callback to handle the result of the initialization GraviteLoader.getInstance().initialize(getApplication(), new IInitializationCallback() { @Override public void onInitialized(boolean isInitialized) { if (isInitialized) { // Gravite initialization succeeded } else { // Gravite initialization failed - handle appropriately } } });

Enable Test Mode / Debug Mode

To test the Gravite feature, use the following code:

// Enable debug mode for Gravite to output additional logs for troubleshooting GraviteLoader.getInstance().enableDebugMode(); // Enable test mode for Gravite with the specified bundle ID and test account ID GraviteLoader.getInstance().enableTestMode("bundleID", "testAccountId", true); // Initialize Gravite with the application context // Provide a callback to handle the result of the initialization GraviteLoader.getInstance().initialize(getApplication(), new IInitializationCallback() { @Override public void onInitialized(boolean isInitialized) { if (isInitialized) { // Gravite initialization succeeded } else { // Gravite initialization failed - handle appropriately } } });

DebugMode

The Debug Mode provides detailed logs to assist with troubleshooting and debugging

EnableTestMode Method
public void enableTestMode(String bundleId, Integer accountId, boolean forceToExecute)

Parameters:

  • bundleId
    Gravite identifies your app using its bundle ID. If you need to use a different bundle ID for publishing, testing, or other purposes, you can override the default bundle ID by specifying an "alternative bundle ID" here.

    • To use the app’s default bundle ID, pass null.

  • accountId
    AATKit’s test mode allows ad testing even before your app is fully set up with Gravite. Use your accountId to activate test mode.

    • If not needed, pass null.

  • forceToExecute
    If set to true, the SDK will bypass normal ad rendering and always call Gravite Ads. This ensures that your application integrates properly with Gravite.

Important Note

Debug Mode and Test Mode must not be enabled in production environments. These modes are intended only for testing and development.

 

Enable Placements Mapping Table

StroeerSDK features a placement mapping capability that automatically translates Stroeer placement names to their corresponding Gravite placements. This eliminates the need to create identical placement names for each provider, streamlining the integration process.

As Gravite doesn’t use ‘zone’ concept, we send only placement names to Gravite.

  • home_b1 → b1

  • zone_b2 → b2

Make sure that your mapping table is based on the placement name for Gravite.

GraviteLoader.getInstance().setPlacementMapTable(new HashMap<>() { { put("b1", "gb1"); put("b2", "gb2"); } });

This configuration ensures that when GraviteLoader processes placements:

  • Stroeer placement b1 will be mapped to Gravite placement gb1.

  • Stroeer placement b2 will be mapped to Gravite placement gb2.

 

Enable Direct Call mode (Experiment)

StroeerSDK provides to call Gravite directly bypassing the Stroeer Ad request. Please contact to Stroeer dealers to discuss about this feature.
To enable Gravite Direct Call, use the following code:

GraviteLoader.getInstance().enableDirectGraviteCall(); GraviteLoader.getInstance().setCacheSize(3);

Gravite includes a pre-load feature to display banners and interstitial ads seamlessly. By default, the cache size is set to 1. However, enabling the direct call feature can cause the cache to empty more frequently, leading to delays while new ads are loaded.

To ensure ads are displayed promptly, consider increasing the cache size. If you notice frequent empty ads in your application, adjusting the cache size can significantly improve performance. The maximum allowable cache size is 5, and increasing it can help maintain a steady flow of ads for your users.

 

5.2 Additional implementation

Gravite requires two specific functions to be called when switching between UI pages. This should be implemented in each Activity.
Failure to implement these methods will result in Gravite advertisements not being rendered properly.

@Override protected void onResume() { super.onResume(); // Resume Gravite ads when the activity is brought to the foreground // This helps with efficient resource management. GraviteLoader.getInstance().onResume(this); } @Override protected void onPause() { super.onPause(); // Pause Gravite ads when the activity is no longer visible // This ensures proper resource management and prevents unnecessary usage. GraviteLoader.getInstance().onPause(this); }

 

5.3 Targeting

If you want to use contextual targeting with Gravite, refer to the following example. While the standard Android manual allows you to use targeting, note that these settings will not be sent to Gravite. Therefore, when Gravite is enabled, ensure you use this specific targeting method. The targeting configured this way will be applied globally.

// Create a map to define custom targeting parameters Map<String, List<String>> map = new HashMap<>(); // Add user-specific data to the targeting map map.put("userAge", List.of("25")); // Example: User's age map.put("userInterest", List.of("sports", "technology", "music")); // Example: User's interests map.put("userLocation", List.of("New York")); // Example: User's location // Apply the custom targeting globally for Gravite Yieldlove.setCustomTargeting(map);