0

I have success integrate the interstitial ad from admob in my application from this tutorial, i want to ask, how to change interstitial ads every X minute

Aan
  • 11
  • 1
  • 1

2 Answers2

0

It is usually not a good idea to show interstitials every minute, because you'll end up interrupting the user flow (interstitial may appear while user is actively using your app). Better use natural breaks to show ads.

Check also the best practices for admob interstitial implementation:

Repeated number of interstitials (not recommended)

Don’t overwhelm users with interstitial ads. Repeated interstitial ads often lead to poor user experiences and accidental clicks. If you’re implementing interstitials based on a user action (e.g., selecting an option), avoid implementing an interstitial ad for every user action.

If you are implementing interstitial ads based on a time interval (e.g., every 60 seconds), avoid using brief durations in between interstitial ads.

donfuxx
  • 11,277
  • 6
  • 44
  • 76
  • Not all game level have long time frame, sometimes between 1 - 3 minute, prevent this case i want to setup interstitial maybe 5 or 10 minute. but i have no idea about java programming – Aan Nov 04 '14 at 13:39
  • If your levels are very short then you should consider showing your ad interstitial only after every 2nd / 3rd level. That way you don't show it too often and you always show it at an appropriate moment in your app. – donfuxx Nov 04 '14 at 17:43
0

It is against google policy but if you still want to implement this

    private void setUpInterstitialAd() {

            interstitialAd = new InterstitialAd(this);
            interstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
            interstitialAd.loadAd(new AdRequest.Builder().build());

            interstitialAd.setAdListener(new AdListener() {
                @Override
                public void onAdClosed() {
                    // Load the next interstitial.
                    interstitialAd.loadAd(new AdRequest.Builder().build());
                }

            });


        }


        private void scheduleInterstitial() {

            ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();

            scheduler.scheduleAtFixedRate(new Runnable() {
                @Override
                public void run() {

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            displayInterstitial();

                            setUpInterstitialAd();
                        }
                    });

                }
            }, 1, 5, TimeUnit.MINUTES);

        }


        private void displayInterstitial() {

            if (interstitialAd != null) {

                if (interstitialAd.isLoaded()) {
                    interstitialAd.show();
                }
            }


        }

 @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setUpInterstitialAd();

        scheduleInterstitial();

    }
kunwar97
  • 775
  • 6
  • 14