简体   繁体   中英

Android Admob rewardedAd not showing rewarded ad

I'm using an admob rewardedAd and everything works fine but sometimes it doesn't show a video. Sometimes it shows a static ad like if it was an intersitial ad. It wouldn't be a problem, but when that happens and the user closes the app, onUserEarnedReward is not fired. Is there a way to force it to always show a rewarded video ad?

Here's the code where I load and prepare the callbacks for the ad:

    rewardedAd = new RewardedAd(this, rewardKey);
    RewardedAdLoadCallback adLoadCallback = new RewardedAdLoadCallback() {
        @Override
        public void onRewardedAdLoaded() { }

        @Override
        public void onRewardedAdFailedToLoad(int errorCode) {
            rewardedAd = new RewardedAd(getApplicationContext(), rewardKey);
            rewardedAd.loadAd(new AdRequest.Builder().build(), this);
        }
    };
    adCallback = new RewardedAdCallback() {
        @Override
        public void onRewardedAdOpened() { }

        @Override
        public void onRewardedAdClosed() {
            rewardedAd = new RewardedAd(getApplicationContext(), rewardKey);
            rewardedAd.loadAd(new AdRequest.Builder().build(), adLoadCallback);
        }

        @Override
        public void onUserEarnedReward(@NonNull RewardItem reward) {
            /* 
            ...
            Give rewards to the user 
            ...
            */
            rewardedAd = new RewardedAd(getApplicationContext(), rewardKey);
            rewardedAd.loadAd(new AdRequest.Builder().build(), adLoadCallback);
        }

        @Override
        public void onRewardedAdFailedToShow(int errorCode) {
            Toast.makeText(getApplicationContext(), getString(R.string.ad_error), Toast.LENGTH_LONG).show();
        }
    };
    rewardedAd.loadAd(new AdRequest.Builder().build(), adLoadCallback);

Then I show it like:

rewardedAd.show(this, adCallback);

from your post it seems the issue does not happen all of the time. try not creating so many new instances of rewardedAd from this code you are calling it three times one should be enough rewardedAd = new RewardedAd(getApplicationContext(), rewardKey);

According to the the documentation there is no such thing as a static rewarded ad:

AdMob rewarded ads may be click-to-download video ads with an end card that appears when the video ends or interactive ads , such as playable ads or surveys.

Are you sure it's not showing an interactive ad such as a survey, where the user must answer a question to get the reward?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM