Search in sources :

Example 1 with RewardItem

use of com.google.android.gms.ads.reward.RewardItem in project Pitampura_Android_2018_Spring by coding-blocks-archives.

the class AdsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ads);
    MobileAds.initialize(this, "ca-app-pub-2481965894320784~1015036453");
    AdView mAdView = findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
    mInterstitialAd.loadAd(new AdRequest.Builder().build());
    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
    mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().build());
    mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {

        @Override
        public void onRewardedVideoAdLoaded() {
        // Show the ad once loaded
        }

        @Override
        public void onRewardedVideoAdOpened() {
        }

        @Override
        public void onRewardedVideoStarted() {
        }

        @Override
        public void onRewardedVideoAdClosed() {
        }

        @Override
        public void onRewarded(RewardItem rewardItem) {
        }

        @Override
        public void onRewardedVideoAdLeftApplication() {
        }

        @Override
        public void onRewardedVideoAdFailedToLoad(int i) {
        }

        @Override
        public void onRewardedVideoCompleted() {
        }
    });
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) RewardedVideoAdListener(com.google.android.gms.ads.reward.RewardedVideoAdListener) RewardItem(com.google.android.gms.ads.reward.RewardItem) InterstitialAd(com.google.android.gms.ads.InterstitialAd) AdView(com.google.android.gms.ads.AdView)

Aggregations

AdRequest (com.google.android.gms.ads.AdRequest)1 AdView (com.google.android.gms.ads.AdView)1 InterstitialAd (com.google.android.gms.ads.InterstitialAd)1 RewardItem (com.google.android.gms.ads.reward.RewardItem)1 RewardedVideoAdListener (com.google.android.gms.ads.reward.RewardedVideoAdListener)1