androidadmobadmob-rewardedvideoad

How can I reload rewarded ad in new API?


I want when the user watched rewarded ad reload it again to be ready in next time.

Code

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_watch);

    MobileAds.initialize(this);
    adRequest = new AdRequest.Builder().build();
    RewardedAd.load(WatchActivity.this, getString(R.string.reward), adRequest, new RewardedAdLoadCallback() {
        @Override
        public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
            mRewardedAd = null;
        }

        @Override
        public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
            mRewardedAd = rewardedAd;
            mRewardedAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                @Override
                public void onAdShowedFullScreenContent() {
                    mRewardedAd = null;
                }

                @Override
                public void onAdDismissedFullScreenContent() {

                }
            });
        }
    });
}

Inside Click Listener

if (mRewardedAd != null) {
        mRewardedAd.show(WatchActivity.this, new OnUserEarnedRewardListener() {
            @Override
            public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
                //I want to reload ad after watch the ad, How can I do it?
            }
        });
}

I can't find anything in Rewarded Ads talking about reload ad.


Solution

  • private void loadRewardedVideoAd() {
            RewardedAd.loadAd(getString(R.string.reward),
                    new AdRequest.Builder().build());
    }
    
    @Override
    public void onRewarded(RewardItem rewardItem) {
            //ProcessRewardedItem and then reload
            loadRewardedVideoAd();
    
    }