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:
importcom.adgatemedia.sdk.classes.AdGateMedia;
To load the offer wall, from any place in your running activity add the following code:
finalHashMap<String,String> subids =newHashMap<String,String>();subids.put("s2","my sub id");AdGateMedia adGateMedia =AdGateMedia.getInstance();adGateMedia.loadOfferWall(YourActivity.this, wallCode, userId, subids,newOnOfferWallLoadSuccess() { @OverridepublicvoidonOfferWallLoadSuccess() {// Here you can call adGateMedia.showOfferWall(); } },newOnOfferWallLoadFailed() { @OverridepublicvoidonOfferWallLoadFailed(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() { @OverridepublicvoidonOfferWallClosed() {// 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:
finalHashMap<String,String> subids =newHashMap<String,String>();subids.put("s2","my sub id");AdGateMedia.getInstance().getConversions(this, wallCode, userId, subids,newOnConversionsReceived() { @OverridepublicvoidonSuccess(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 ); } } @OverridepublicvoidonError(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: