RewardedVideo广告集成说明
激励视频(RewardedVideo)
1. 确定AdHubSDK的主SDK文件已经拷贝到工程文件的libs子目录下参考
2. 添加广告代码,添加广告代码前请确定已初始化SDK
- 例如:
// Query RewaredVideoAd interface.
RewardedVideoAd mRewardedVideoAd = AdHub.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
if (!mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.loadAd(mAdUnitId, new AdRequest.Builder().build());
}
- 获取RewardedVideoAd:
RewardedVideoAd mRewardedVideoAd = AdHub.getRewardedVideoAdInstance(this);
- 构造AdRequest:
AdRequest adRequest = new AdRequest.Builder().build();
属性设置: mRewardedVideoAd.setAdListener(adListener); // 设置事件监听器 mRewardedVideoAd.isLoaded(); // 广告是否加载
控制接口: mRewardedVideoAd.loadAd(mAdUnitId, adRequest); // 加载广告
RewardedVideoAdListener接口定义:
// A listener for receiving notifications during the lifecycle of a rewarded video ad.
public interface RewardedVideoAdListener {
// Called when a rewarded video ad has triggered a reward. The app is
// responsible for crediting the user with the reward.
public abstract void onRewarded(RewardItem reward);
// Called when a rewarded video ad is closed.
public abstract void onRewardedVideoAdClosed();
// Called when a rewarded video ad is visible.
public abstract void onRewardedVideoAdShown();
// Called when a rewarded video ad request logFailed.
public abstract void onRewardedVideoAdFailedToLoad(int errorCode);
// Called when a rewarded video ad leaves the application(e.g., to go to the browser).
public abstract void onRewardedVideoAdLeftApplication();
// Called when a rewarded video ad is loaded.
public abstract void onRewardedVideoAdLoaded();
// Called when a rewarded video ad opens a overlay that covers the screen.
public abstract void onRewardedVideoAdOpened();
// Called when a rewarded video ad starts to play.
public abstract void onRewardedVideoStarted();
}
PS:更多设置请参考Demo中的com.hubcloud.adhubsdkdemo.RewarededVideoActivity的代码.