项目作者: iammert

项目描述 :
Sample project to show rewarded ads on your android app
高级语言: Java
项目地址: git://github.com/iammert/rewarded-ads-sample.git
创建时间: 2017-06-03T22:31:05Z
项目社区:https://github.com/iammert/rewarded-ads-sample

开源协议:

下载


rewarded-ads-sample

Sample project to show rewarded ads on your android app

Usage

  1. public class MainActivity extends AppCompatActivity implements RewardedVideoListener{
  2. @Override
  3. protected void onCreate(Bundle savedInstanceState) {
  4. ...
  5. RewardedAd rewardedAd = RewardedAdFactory.getRewardedAd(this, AdType.ADMOB, this);
  6. rewardedAd.showAd();
  7. ...
  8. }
  9. @Override
  10. public void onVideoCompleted() {
  11. Log.v("TEST", "Video completed.");
  12. }
  13. @Override
  14. public void onVideoLoadFailed() {
  15. Log.v("TEST", "Video failed.");
  16. }
  17. @Override
  18. public void onVideoStarted() {
  19. Log.v("TEST", "Video started.");
  20. }
  21. }

3 ad network types are supported. PR’s are welcome for other ad networks.

  1. AdType.ADMOB
  2. AdType.CHARTBOOST
  3. AdType.STARTAPP

Handling Lifecycle

LifeCycleRegistry is used to handle lifecycle in Ad instances.

  1. LifecycleRegistry lifecycleRegistry = new LifecycleRegistry(this);
  2. lifecycleRegistry.addObserver(rewardedAd.getObserver());

Replace Keys

  1. <!-- Chartboost -->
  2. <string name="chartboost_app_id">[REPLACE_CHARTBOOST_APP_ID]</string>
  3. <string name="chartboost_app_signature">[REPLACE_CHARTBOOST_APP_SIGNATURE]</string>
  4. <!-- Admob -->
  5. <string name="admob_unit_id">[REPLACE_ADMOB_AD_UNIT_ID]</string>
  6. <!-- Startapp -->
  7. <string name="startapp_app_id">[REPLACE_STARTAPP_APP_ID]</string>