How many times and on what method should the ads be loaded?

Viewed 32

So I am trying to understand how many times an add must be loaded if it will shown when the user clicks on a button. On the official implementation guide, it is done once on the onCreate method. So could I put it onStart method? Or maybe onResume method? So my question is, in my example, how many times and on what method should I call CallNewInertial()? This is my code:

  private void CallNewInertial() {
        ConnectionDetector cd = new ConnectionDetector(MainActivity.this);
        if (cd.isConnectingToInternet()) {
            requestNewInterstitial();
        }

    private void requestNewInterstitial() {
        AdRequest adRequest = new AdRequest.Builder().build();
        InterstitialAd.load(MainActivity.this, getString(R.string.adMob_interstitial),
                adRequest, new InterstitialAdLoadCallback() {
                    @Override
                    public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
                        mInterstitialAd = interstitialAd;
                    }

                    @Override
                    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                        mInterstitialAd = null;
                        requestNewInterstitial();
                    }
                });
    }


private void OnClick(){
       if (mInterstitialAd != null ) {

                    mInterstitialAd.show(MainActivity.this);

                    mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                        @Override
                        public void onAdDismissedFullScreenContent() {
                           // SUPPOSE that startactivity moves to another activity;
                            startActivity(i);

                        }

                        @Override
                        public void onAdFailedToShowFullScreenContent(@NonNull AdError adError) {

                        }



                    });

                }
}
1 Answers

Calling it in onCreate() would be the best programming practice to load the ad on the creation of the activity then you can show the ad complying with the Interstitial ad flow and guidance. As said in guidance:

Don't surprise users with interstitial ads. Placing interstitial ads so that they suddenly appear when a user is focused on a task at hand may lead to accidental clicks and often creates a frustrating user experience

If you think that whenever user comes back to this activity from another activity and interstitial should be shown then you can call CallNewInertial() in onStart() method because onCreate() won't be called here and your ad won't be loaded.

Depends on the use case although I don't recommend overwhelming the user with interstitial ads on the same activity again and again because as said in guidance:

Don't overwhelm users with interstitial ads. Repeated interstitial ads often lead to poor user experiences and accidental clicks.

So I would say just go through with the flow and guidance of the interstitial ads then you can make this decision.

Related