> For the complete documentation index, see [llms.txt](https://docs.prodegeads.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.prodegeads.com/adgate-rewards-monetization/android-sdk.md).

# Android SDK

This page describes how to install the AdGate Media iOS SDK.

## Requirements

* Android SDK minimum version 14 (Ice Cream Sandwich 4.0)
* Minimum hardware requirement is ARMV7
* Java JDK 1.6 or greater

## 1. Install SDK

> Instructions provided here are for Android Studio. aar libraries are not yet supported on Eclipse, though some solutions are available online.

1. Download the latest aar file from <https://github.com/adgatemedia/adgate-rewards-android-sdk/releases>
2. Add the aar file to your project, by copying it into your project's libs folder.

   ![image1](https://cloud.githubusercontent.com/assets/12953988/11656906/54b19416-9dde-11e5-8c65-49dcd16c9fd2.png)
3. Add the following lines of code to your app's `build.gradle` file, so that Android Studio recognizes and builds the library along with your app.

```markup
repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    implementation 'com.google.android.gms:play-services-iid:10.2.1'
    implementation 'com.google.android.gms:play-services-ads:10.2.1'
    implementation 'com.google.code.gson:gson:2.8.0'
    implementation 'com.squareup.okio:okio:1.12.0'
    implementation 'com.squareup.okhttp3:okhttp:3.7.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.facebook.network.connectionclass:connectionclass:1.0.1'
    implementation(name:'adgatemediasdk', ext:'aar')
}
```

At this point Android Studio shouldn't throw any errors related to the library.

## 2. Load the offer wall

1. In your activity, where you intend to show the offer wall, add the following import statement:

```java
import com.adgatemedia.sdk.classes.AdGateMedia;
```

1. To load the offer wall, from any place in your running activity add the following code:

```java
   final HashMap<String, String> subids = new HashMap<String, String>();
   subids.put("s2", "my sub id");
   AdGateMedia adGateMedia = AdGateMedia.getInstance();

   adGateMedia.loadOfferWall(YourActivity.this,
                   wallCode,
                   userId,
                   subids,
                   new OnOfferWallLoadSuccess() {
                       @Override
                       public void onOfferWallLoadSuccess() {
                           // Here you can call adGateMedia.showOfferWall();
                       }
                   },
                   new OnOfferWallLoadFailed() {
                       @Override
                       public void onOfferWallLoadFailed(String reason) {
                           // Here you handle the errors with provided reason
                       }
                   });
```

Remember to set `wallCode` and `userId` to the appropriate values. You can get your AdGate Rewards wall code from the [Dashboard](https://panel.adgatemedia.com/affiliate/vc-walls/index). The `userId` values can be any alphanumeric string. You may add up to 4 subid strings to the HashMap: s2, s3, s4, and s5.

## 3. Display the offer wall

Once offer wall is loaded you can display it by calling the showOfferWall method.

```java
    AdGateMedia.getInstance().showOfferWall(YourActivity.this,
                                new AdGateMedia.OnOfferWallClosed() {
                                    @Override
                                    public void onOfferWallClosed() {
                                        // Here you handle the 'Offer wall has just been closed' event
                                    }
                                });
```

## 4. Get a list of the latest offer wall conversions

To get a list of latest offer wall conversions for a particular user run the following code in your activity:

```java
   final HashMap<String, String> subids = new HashMap<String, String>();
   subids.put("s2", "my sub id");

   AdGateMedia.getInstance().getConversions(this, wallCode, userId, subids, new OnConversionsReceived() {
      @Override
      public void onSuccess(List<Conversion> conversions) {
          // Here you can loop through every conversion and process it.
          // conversions.size() holds the amount of new conversions to process.
          for (Conversion conversion : conversions)  {
              Log.i("AdGateRewards", "Received new conversion: " +
              "offer ID: " + String.valueOf(conversion.offerId) +
              " offer title: " + conversion.title +
              " transaction ID: " + conversion.txId +
              " points earned: " + String.valueOf(conversion.points) +
              " payout in cents:" + String.valueOf(conversion.payout) +
              " subid 2: "+conversion.subid2 +
              " subid 3: "+conversion.subid3 +
              " subid 4: "+conversion.subid4 +
              " subid 5: "+conversion.subid5
              );
          }
      }

      @Override
      public void onError(String message) {
          // Fired when any error occurs
      }
   });
```

The `wallCode` for your AdGate Rewards wall can be found on the [AdGate Rewards panel page](https://panel.adgatemedia.com/affiliate/vc-walls). The `userId` value is your app's internal user id for whom you'd like to check for conversions. `subids` is a hashmap of the subid's that was used when loading the offer wall.

If the call was successful, a list of conversions is passed to the `onSuccess` method. Each Conversion model has the following class definition:

```java
public class Conversion implements Serializable {
    public int offerId;
    public String title;
    public String txId;
    public double points;
    public int payout; // in cents USD
    public String subid2;
    public String subid3;
    public String subid4;
    public String subid5;
}
```

## 6. Enable console messages

To enable debugging, warning, and error messages run the following line of code:

```java
   AdGateMedia.getInstance().setDebugMode(true);
```

This will log messages to the console as well as to a log file. Make sure you disable debug mode before publishing your app to the Google Play Store.

## 7. Demo app

[This repository](https://github.com/adgatemedia/adgate-rewards-android-sdk) contains a demo Android app that shows how to implement our SDK.
