Skip to main content

OfferWall

Step 1.Prerequisites#

This document mainly introduces how to integrate Offerwall Ads :

  • Use Android Studio 2.2 or later
  • minSdkVersion 16 or later
  • compileSdkVersion 28 or later
  • Recommended: Create your TradPlus Apps and get your AppId
  • Initialize the TradPlus SDK for Android

Step 2.Integration#

2.1 Create an Offerwall ad#

(1)V6.X New API#

/**
* @param context activity or application context
* @param AdUnitId create adUnit Id from your App
* @param Autostitial Ads show an ad automatically between activities,pass true to set auto load Mode.
*/
TPOfferWall tpOfferWall = new TPOfferWall(context, "AdUnitId", true);

(2)V5.X Old API#

TradPlusInterstitialExt mTradPlusOfferWall = new TradPlusInterstitialExt(context, "adUnitId");
mTradPlusOfferWall.setCanLoadListener(new CanLoadListener() {
@Override
public void canLoad() {
//The first load the ad needs to be requested in the CanLoad() callback
mTradPlusOfferWall.load();
}
});
//Initialize the UnitId
mTradPlusOfferWall.initUnitId();

2.2 Implement Event Listeners#

(1)V6.X New API#

tpOfferWall.setAdListener(new OfferWallAdListener() {
@Override
public void onAdLoaded(TPAdInfo tpAdInfo) {
// Called when the ad for the given adUnitId has loaded.
}
@Override
public void onAdClicked(TPAdInfo tpAdInfo) {
// Called when a offerwall ad is clicked.
}
@Override
public void onAdImpression(TPAdInfo tpAdInfo) {
// Called when a offerwall ad starts playing.
}
@Override
public void onAdFailed(TPAdError tpAdError) {
// Called when the ad for the given adUnitId has failed.
}
@Override
public void onAdClosed(TPAdInfo tpAdInfo) {
// Called when a offerwall ad is closed.
}
@Override
public void onAdReward(TPAdInfo tpAdInfo) {
// Called when the offerwall is completed and the user should be rewarded.
}
});

(2)V5.X Old API#

//针对广告位下每个广告源的回调监听
mTradPlusOfferWall.setInterstitialAdListener(new TradPlusInterstitial.InterstitialAdListener() {
@Override
public void onInterstitialLoad(TradPlusInterstitial interstitial) {}
@Override
public void onInterstitialLoaded(final TradPlusInterstitial tradPlusInterstitial) {
// Called when the ad for the given adUnitId has loaded.
}
@Override
public void onInterstitialFailed(final TradPlusInterstitial tradPlusInterstitial, final TradPlusErrorCode tradPlusErrorCode) {
// Called when the ad for the given adUnitId has failed.
}
@Override
public void onInterstitialShown(final TradPlusInterstitial tradPlusInterstitial) {
// Called when a offerwall ad starts playing.
}
@Override
public void onInterstitialClicked(TradPlusInterstitial tradPlusInterstitial) {
// Called when a offerwall ad is clicked.
}
@Override
public void onInterstitialDismissed(final TradPlusInterstitial tradPlusInterstitial) {
// Called when a offerwall ad is closed.
mTradPlusOfferWall.load();
}
@Override
public void onInterstitialRewarded(TradPlusInterstitial tradPlusInterstitial, String s, int i) {
// Called when the offerwall is completed and the user should be rewarded.
}
});

2.2 Load an Ad#

(1)V6.X New API#

tpOfferWall.loadAd();

(2)V5.X Old API#

mTradPlusOfferWall.load();

2.4 Check is Ready#

Before show an Ad , using the isReady() method to make sure you have available ads.

(1)V6.X New API#

tpOfferWall.isReady()

(2)V5.X Old API#

mTradPlusOfferWall.isReady();

2.5 show an Ad#

(1)V6.X New API#

//@param:ViewGroup
//@param:pass empty string
tpOfferWall.showAd(Activity context,"");

(2)V5.X Old API#

mTradPlusOfferWall.show();