import com.intowow.sdk.RewardedVideoAd;
private RewardedVideoAd mRewardedVideoAd = null;
private final static String PLACEMENT_NAME = "Obtain from your Intowow account manager";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRewardedVideoAd = new RewardedVideoAd(mActivity);
}
NOTE :
please make sure to pass Activity on to the RewardedVideoAd.
Setup the RequestInfo
You need to set the placement ID and the request timeout in requestInfo.
RequestInfo requestInfo = new RequestInfo();
requestInfo.setPlacement(PLACEMENT_NAME);
requestInfo.setTimeout(timeout);
Load ad with RequestInfo
loadAdInstant
import com.intowow.sdk.CERequestResult;
CERequsetResult result = mRewardedVideoAd.loadAdInstant(requestInfo);
if (result.isSuccess()) {
// TODO: Attach the Ad View
} else {
// You can call result.getError() to know info of loadAd fail
}
}
loadAdAsync
import com.intowow.sdk.CEAdRequestListener;
import com.intowow.sdk.CERewardedVideoAdListener;
mRewardedVideoAd.loadAdAsync(requestInfo, new CEAdRequestListener() {
@Override
public void onError(Ad ad, AdError error) {
}
@Override
public void onAdLoaded(Ad ad) {
// Start InterstitialAdActivity for showing this ad.
//
mRewardedVideoAd.show();
}
});
Add CERewardedVideoAdListener to get the result of ad request and ad event callback.
import com.intowow.sdk.Ad;
import com.intowow.sdk.AdError;
import com.intowow.sdk.RewardedVideoAd;
import com.intowow.sdk.CERewardedVideoAdListener;
private RewardedVideoAd mRewardedVideoAd = null;
private final static String PLACEMENT_NAME = "Obtain from your Intowow account manager";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRewardedVideoAd = new RewardedVideoAd(mActivity, PLACEMENT_NAME);
mRewardedVideoAd.setAdListener(new CERewardedVideoAdListener() {
@Override
public void onAdDisplayed(Ad ad) {
}
@Override
public void onAdDismissed(Ad ad) {
}
@Override
public void onAdClicked(Ad ad) {
}
@Override
public void onAdImpression(Ad ad) {
}
@Override
public void onAdMute(Ad ad) {
}
@Override
public void onAdUnmute(Ad ad) {
}
@Override
public void onVideoEnd(Ad arg0) {
}
@Override
public void onVideoProgress(Ad arg0, int totalDuration, int currentPosition) {
}
@Override
public void onVideoStart(Ad arg0) {
}
});
}
There are two options to handle landscape orientation.
Add android:configChanges="orientation|screenSize in AndroidManifest.xml.
If ad is displayed in landscape mode, your Activity will be recreated. You can have a variable to remember if you’ve requested rewardedVideoAd ad or not in onSaveInstanceState(). Later you can retrieve that variable in onCreate() and avoid requesting rewarded ad twice. See BaseActivity.java in sample app source code.