How to find if an ad is available without loading the ad?

987 Views Asked by At

Is there any way to find if an ad is available for a user or not, especially for a reward video?

I want to check if an ad is available without loading the ad, and then display a reward button only if the ad is available. Right now I have to load the whole ad before showing reward button to users, which wastes resources because there is no way to know if the user will press the reward button or not.

I want to confirm before showing reward button that there is ad available for the particular user, without loading/caching the full video ad.

1

There are 1 best solutions below

3
AAryan On

Always keep your Video Ad in cache (Available in cache but not shown yet). When you request/load, an Ad fetched from server but not appear in front of user, only appear when you call show() on Ad.

@Override
public boolean showVideoAd(){

     isRewardShown=false;
     activity.runOnUiThread(new Runnable() {
                public void run() {

                    if (mAd.isLoaded()) {
                        mAd.show();
                        isRewardShown=true;

                    } else {
                        loadRewardedVideoAd();
                    }
                }

            });

    return isRewardShown;
}

private void loadRewardedVideoAd() {
    mAd.loadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().build());
}

show rewardButton only when mAd.isLoaded(), return true. If User click on rewardButton then call showVideoAd otherwise no problem you have already that Reward video is in cached, may be use for next time.