I will show you How to Show Interstitial Ad every X Seconds. That is you can show an Interstitial ad for every fixed number of seconds for example 10, 20, 30 or more…
Watch Below Video for and at bottom you will get link for source code
Add Below Library to your Gradle
compile 'com.google.android.gms:play-services-ads:10.2.4'
Add Below code to your MainActivity.java file
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.widget.Toast; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.InterstitialAd; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; public class MainActivity extends AppCompatActivity { private InterstitialAd mInterstitialAd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); prepareAd(); ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.scheduleAtFixedRate(new Runnable() { public void run() { Log.i("hello", "world"); runOnUiThread(new Runnable() { public void run() { if (mInterstitialAd.isLoaded()) { mInterstitialAd.show(); } else { Log.d("TAG"," Interstitial not loaded"); } prepareAd(); } }); } }, 10, 10, TimeUnit.SECONDS); } public void prepareAd(){ mInterstitialAd = new InterstitialAd(this); mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712"); mInterstitialAd.loadAd(new AdRequest.Builder().build()); } }