C
C
Chesterfield252021-11-19 23:25:36
Java
Chesterfield25, 2021-11-19 23:25:36

Why does it show only one ad?

I made an application for downloading videos from facebook. The link to the video is inserted into the edittext and when you click on the button, the video is downloaded. I added an admob reward so that when you click on the button, a video ad is shown and then the video is downloaded. When using test ads, when I open the application, I insert a link in the field and click on the download button, one test ad is shown, after which the video is downloaded, but when I insert the second download link and click download, nothing happens, the ad is not shown and, accordingly, the video is not downloaded. My assumption is that this happens because I use test video ads, and in test mode there is only one video ad, so when you download again, nothing happens! What do you say to that?

My ad code

MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
        });

AdRequest adRequest = new AdRequest.Builder().build();

RewardedAd.load(this, "ca-app-pub-3940256099942544/5224354917",
                adRequest, new RewardedAdLoadCallback() {
                    @Override
                    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                        // Handle the error.
                        Log.d("TAG", loadAdError.getMessage());
                        mRewardedAd = null;
                    }

                    @Override
                    public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
                        mRewardedAd = rewardedAd;
                        Log.d("TAG", "Ad was loaded.");
                    }
                });


The code of the button, when clicked, which displays a video ad and downloads the video

binding.download.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (mRewardedAd != null) {
                    Activity activityContext = MainActivity.this;
                    mRewardedAd.show(activityContext, new OnUserEarnedRewardListener() {
                        @Override
                        public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
                            // Handle the reward.
                            Log.d("TAG", "The user earned the reward.");
                            int rewardAmount = rewardItem.getAmount();
                            String rewardType = rewardItem.getType();
                            getFaceBookData();
                        }
                    });
                } else {
                    Log.d("TAG", "The rewarded ad wasn't ready yet.");
                }

            }
        });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question