Advertisement
solodroid

Untitled

Dec 13th, 2016
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.         ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
  2.         scheduler.scheduleAtFixedRate(new Runnable() {
  3.  
  4.             public void run() {
  5.                 runOnUiThread(new Runnable() {
  6.                     public void run() {
  7.  
  8.                         interstitialAd = new InterstitialAd(MainActivity.this);
  9.                         interstitialAd.setAdUnitId(getString(R.string.admob_interstitial_id));
  10.                         AdRequest adRequest = new AdRequest.Builder().build();
  11.                         interstitialAd.loadAd(adRequest);
  12.                         interstitialAd.setAdListener(new AdListener() {
  13.                             public void onAdLoaded() {
  14.                                 if (interstitialAd.isLoaded()) {
  15.                                     interstitialAd.show();
  16.                                 }
  17.                             }
  18.                         });
  19.  
  20.                     }
  21.                 });
  22.  
  23.             }
  24.         }, 120, 120, TimeUnit.SECONDS);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement