RewardedVideo广告集成说明
激励视频(RewardedVideo)
1. 确定AdHubSDK的主SDK文件已经拷贝到工程文件的libs子目录下参考
2. 添加广告代码,添加广告代码前请确定已初始化SDK
例如:
RewardedVideoAd mRewardedVideoAd = AdHub.getRewardedVideoAdInstance(this); mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() { @Override public void onRewarded(RewardItem rewardItem) { Log.d("lance", "onRewarded:" + rewardItem.getType() + "==" + rewardItem.getAmount()); } @Override public void onRewardedVideoAdClosed() { Log.d("lance", "onRewardedVideoAdClosed"); } @Override public void onRewardedVideoAdShown() { Log.d("lance", "onRewardedVideoAdShown"); } @Override public void onRewardedVideoAdFailedToLoad(int i) { Log.d("lance", "onRewardedVideoAdFailedToLoad:" + i); } @Override public void onRewardedVideoAdLeftApplication() { Log.d("lance", "onRewardedVideoAdLeftApplication"); } @Override public void onRewardedVideoAdLoaded() { Log.d("lance", "onRewardedVideoAdLoaded"); if (mRewardedVideoAd.isLoaded()) { mRewardedVideoAd.show(); } } @Override public void onRewardedVideoAdOpened() { Log.d("lance", "onRewardedVideoAdOpened"); } @Override public void onRewardedVideoStarted() { Log.d("lance", "onRewardedVideoStarted"); } }); if (!mRewardedVideoAd.isLoaded()) { mRewardedVideoAd.loadAd("435", new AdRequest.Builder().build()); }
注意生命周期回调:
@Override public void onPause() { super.onPause(); mRewardedVideoAd.pause(this); } @Override public void onResume() { super.onResume(); mRewardedVideoAd.resume(this); } @Override protected void onDestroy() { super.onDestroy(); mRewardedVideoAd.destroy(this); }
PS:更多设置请参考Demo中的com.hubcloud.adhubsdkdemo.RewarededVideoActivity的代码.