How To Show Interstitial Ads After Every Desired Seconds In Android Studio?

interstitial ads android

In this tutorial, we will learn how we can show interstitial ads after every any number of seconds. For that, you have to follow following steps.

Step 1.

Open and add following code in it.

compile ‘’

Step 2.

Open and add following code


import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;


import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MainActivity extends AppCompatActivity {

private InterstitialAd mInterstitialAd;

protected void onCreate(Bundle savedInstanceState) {


ScheduledExecutorService scheduler =
scheduler.scheduleAtFixedRate(new Runnable() {

public void run() {
Log.i(“hello”, “world”);
runOnUiThread(new Runnable() {
public void run() {
if (mInterstitialAd.isLoaded()) {;
} else {
Log.d(“TAG”,” Interstitial not loaded”);



}, 10, 10, TimeUnit.SECONDS);


public void prepareAd(){

mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.loadAd(new AdRequest.Builder().build());

Replace ad unit id with your own.


This is how we can show interstitial ads after some seconds. Please don’t show too many ads because it can be against Admob policies. 

Gaurav singla

Founder of I write blogs about android tutorials, blogging tips, programming etc.

You may also like...

1 Response

  1. Vipin Chaudhary says:

    Ads keep on popping app after the app is in background.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: