At this point Android Studio shouldn't throw any errors related to the library.
2. Load the offer wall
In your activity, where you intend to show the offer wall, add the following import statement:
import com.adgatemedia.sdk.classes.AdGateMedia;
To load the offer wall, from any place in your running activity add the following code:
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. 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.
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:
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. 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:
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:
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 contains a demo Android app that shows how to implement our SDK.