how to show admob interstitial on app start











up vote
0
down vote

favorite












I need help
how to show admob interstitial on app start
i want to trigger the admon interstitial when app launched
for the record my app is a swipe tab content
Pleas i need any solution
any one have an idea



public class MainActivity extends FragmentActivity implements
ActionBar.TabListener {

private InterstitialAd interstitial;

private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private ActionBar actionBar;
// Tab titles


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("");

//google ads Banner
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
ActionBar actionBar = getActionBar();

// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("ca-app-pub-1417847946178022/7723890794");

// Create ad request.
adRequest = new AdRequest.Builder().build();

// Begin loading your interstitial.
interstitial.loadAd(adRequest);


// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

// Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name)
.setTabListener(this));
}

/**
* on swiping the viewpager make respective tab selected
* */
final ActionBar finalActionBar = actionBar;
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

@Override
public void onPageSelected(int position) {
// on changing the page
// make respected tab selected
finalActionBar.setSelectedNavigationItem(position);
}

@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}

@Override
public void onPageScrollStateChanged(int arg0) {
}
});




interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
displayInterstitial();
}
});


}

// Invoke displayInterstitial() when you are ready to display an interstitial.
public void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
}


}


@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}


}









share|improve this question


























    up vote
    0
    down vote

    favorite












    I need help
    how to show admob interstitial on app start
    i want to trigger the admon interstitial when app launched
    for the record my app is a swipe tab content
    Pleas i need any solution
    any one have an idea



    public class MainActivity extends FragmentActivity implements
    ActionBar.TabListener {

    private InterstitialAd interstitial;

    private ViewPager viewPager;
    private TabsPagerAdapter mAdapter;
    private ActionBar actionBar;
    // Tab titles


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    // Create the interstitial.
    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId("");

    //google ads Banner
    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    ActionBar actionBar = getActionBar();

    // Create the interstitial.
    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId("ca-app-pub-1417847946178022/7723890794");

    // Create ad request.
    adRequest = new AdRequest.Builder().build();

    // Begin loading your interstitial.
    interstitial.loadAd(adRequest);


    // Initilization
    viewPager = (ViewPager) findViewById(R.id.pager);
    actionBar = getActionBar();
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(mAdapter);
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Adding Tabs
    for (String tab_name : tabs) {
    actionBar.addTab(actionBar.newTab().setText(tab_name)
    .setTabListener(this));
    }

    /**
    * on swiping the viewpager make respective tab selected
    * */
    final ActionBar finalActionBar = actionBar;
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

    @Override
    public void onPageSelected(int position) {
    // on changing the page
    // make respected tab selected
    finalActionBar.setSelectedNavigationItem(position);
    }

    @Override
    public void onPageScrolled(int arg0, float arg1, int arg2) {
    }

    @Override
    public void onPageScrollStateChanged(int arg0) {
    }
    });




    interstitial.setAdListener(new AdListener() {
    public void onAdLoaded() {
    displayInterstitial();
    }
    });


    }

    // Invoke displayInterstitial() when you are ready to display an interstitial.
    public void displayInterstitial() {
    if (interstitial.isLoaded()) {
    interstitial.show();
    }


    }


    @Override
    public void onTabReselected(Tab tab, FragmentTransaction ft) {
    }

    @Override
    public void onTabSelected(Tab tab, FragmentTransaction ft) {
    // on tab selected
    // show respected fragment view
    viewPager.setCurrentItem(tab.getPosition());
    }

    @Override
    public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    }


    }









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I need help
      how to show admob interstitial on app start
      i want to trigger the admon interstitial when app launched
      for the record my app is a swipe tab content
      Pleas i need any solution
      any one have an idea



      public class MainActivity extends FragmentActivity implements
      ActionBar.TabListener {

      private InterstitialAd interstitial;

      private ViewPager viewPager;
      private TabsPagerAdapter mAdapter;
      private ActionBar actionBar;
      // Tab titles


      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);


      // Create the interstitial.
      interstitial = new InterstitialAd(this);
      interstitial.setAdUnitId("");

      //google ads Banner
      AdView mAdView = (AdView) findViewById(R.id.adView);
      AdRequest adRequest = new AdRequest.Builder().build();
      mAdView.loadAd(adRequest);
      ActionBar actionBar = getActionBar();

      // Create the interstitial.
      interstitial = new InterstitialAd(this);
      interstitial.setAdUnitId("ca-app-pub-1417847946178022/7723890794");

      // Create ad request.
      adRequest = new AdRequest.Builder().build();

      // Begin loading your interstitial.
      interstitial.loadAd(adRequest);


      // Initilization
      viewPager = (ViewPager) findViewById(R.id.pager);
      actionBar = getActionBar();
      mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

      viewPager.setAdapter(mAdapter);
      actionBar.setHomeButtonEnabled(false);
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

      // Adding Tabs
      for (String tab_name : tabs) {
      actionBar.addTab(actionBar.newTab().setText(tab_name)
      .setTabListener(this));
      }

      /**
      * on swiping the viewpager make respective tab selected
      * */
      final ActionBar finalActionBar = actionBar;
      viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

      @Override
      public void onPageSelected(int position) {
      // on changing the page
      // make respected tab selected
      finalActionBar.setSelectedNavigationItem(position);
      }

      @Override
      public void onPageScrolled(int arg0, float arg1, int arg2) {
      }

      @Override
      public void onPageScrollStateChanged(int arg0) {
      }
      });




      interstitial.setAdListener(new AdListener() {
      public void onAdLoaded() {
      displayInterstitial();
      }
      });


      }

      // Invoke displayInterstitial() when you are ready to display an interstitial.
      public void displayInterstitial() {
      if (interstitial.isLoaded()) {
      interstitial.show();
      }


      }


      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
      }

      @Override
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
      // on tab selected
      // show respected fragment view
      viewPager.setCurrentItem(tab.getPosition());
      }

      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
      }


      }









      share|improve this question













      I need help
      how to show admob interstitial on app start
      i want to trigger the admon interstitial when app launched
      for the record my app is a swipe tab content
      Pleas i need any solution
      any one have an idea



      public class MainActivity extends FragmentActivity implements
      ActionBar.TabListener {

      private InterstitialAd interstitial;

      private ViewPager viewPager;
      private TabsPagerAdapter mAdapter;
      private ActionBar actionBar;
      // Tab titles


      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);


      // Create the interstitial.
      interstitial = new InterstitialAd(this);
      interstitial.setAdUnitId("");

      //google ads Banner
      AdView mAdView = (AdView) findViewById(R.id.adView);
      AdRequest adRequest = new AdRequest.Builder().build();
      mAdView.loadAd(adRequest);
      ActionBar actionBar = getActionBar();

      // Create the interstitial.
      interstitial = new InterstitialAd(this);
      interstitial.setAdUnitId("ca-app-pub-1417847946178022/7723890794");

      // Create ad request.
      adRequest = new AdRequest.Builder().build();

      // Begin loading your interstitial.
      interstitial.loadAd(adRequest);


      // Initilization
      viewPager = (ViewPager) findViewById(R.id.pager);
      actionBar = getActionBar();
      mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

      viewPager.setAdapter(mAdapter);
      actionBar.setHomeButtonEnabled(false);
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

      // Adding Tabs
      for (String tab_name : tabs) {
      actionBar.addTab(actionBar.newTab().setText(tab_name)
      .setTabListener(this));
      }

      /**
      * on swiping the viewpager make respective tab selected
      * */
      final ActionBar finalActionBar = actionBar;
      viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

      @Override
      public void onPageSelected(int position) {
      // on changing the page
      // make respected tab selected
      finalActionBar.setSelectedNavigationItem(position);
      }

      @Override
      public void onPageScrolled(int arg0, float arg1, int arg2) {
      }

      @Override
      public void onPageScrollStateChanged(int arg0) {
      }
      });




      interstitial.setAdListener(new AdListener() {
      public void onAdLoaded() {
      displayInterstitial();
      }
      });


      }

      // Invoke displayInterstitial() when you are ready to display an interstitial.
      public void displayInterstitial() {
      if (interstitial.isLoaded()) {
      interstitial.show();
      }


      }


      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
      }

      @Override
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
      // on tab selected
      // show respected fragment view
      viewPager.setCurrentItem(tab.getPosition());
      }

      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
      }


      }






      android admob interstitial






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 25 '15 at 16:11









      Silent Joker

      1




      1
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote













          Note that according to the disallowed admob implementations:




          App load or exit



          Do not place interstitial ads on app load and when exiting apps as interstitials should only be placed in between pages of app content.




          Failure to adhere to this policy might lead to the disabling of ad-serving to your app.



          If you still want this, you can display in your onResume's method:



          boolean isAdShown;

          @Override
          protected void onResume() {
          super.onResume();
          if (!isAdShown) {
          displayInterstitial();
          isAdShown = true;
          }
          }





          share|improve this answer























          • No I don't want this Give me an allowed method . please
            – Silent Joker
            Aug 26 '15 at 15:14










          • So you mean I should use onPause() method . ok then just show me with codes
            – Silent Joker
            Aug 26 '15 at 16:29


















          up vote
          -1
          down vote













          You should not place interstitial ads on app load and when exiting apps as However. You can show Interstitial after app load, with such practice you have to implement a splash screen in your app and show interstitial after it.




          An interstitial ad launches while the user is idle on the ‘Home
          Screen’ of the app. This implementation is in violation of our
          policies . One potential way to fix this violation, would be to
          implement a splash page that launches as the first screen of the app,
          before the ‘Home Screen’. The Interstitial ad should then launch in
          the transition between the splash screen and the ‘Home Screen’.




          Reference : -- > Google Blog






          share|improve this answer























          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
            – Eray Balkanli
            Nov 8 at 14:28










          • Couldn't agree more, just updated the answer, Thanks
            – Aegon
            Nov 8 at 20:42











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32208974%2fhow-to-show-admob-interstitial-on-app-start%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          Note that according to the disallowed admob implementations:




          App load or exit



          Do not place interstitial ads on app load and when exiting apps as interstitials should only be placed in between pages of app content.




          Failure to adhere to this policy might lead to the disabling of ad-serving to your app.



          If you still want this, you can display in your onResume's method:



          boolean isAdShown;

          @Override
          protected void onResume() {
          super.onResume();
          if (!isAdShown) {
          displayInterstitial();
          isAdShown = true;
          }
          }





          share|improve this answer























          • No I don't want this Give me an allowed method . please
            – Silent Joker
            Aug 26 '15 at 15:14










          • So you mean I should use onPause() method . ok then just show me with codes
            – Silent Joker
            Aug 26 '15 at 16:29















          up vote
          1
          down vote













          Note that according to the disallowed admob implementations:




          App load or exit



          Do not place interstitial ads on app load and when exiting apps as interstitials should only be placed in between pages of app content.




          Failure to adhere to this policy might lead to the disabling of ad-serving to your app.



          If you still want this, you can display in your onResume's method:



          boolean isAdShown;

          @Override
          protected void onResume() {
          super.onResume();
          if (!isAdShown) {
          displayInterstitial();
          isAdShown = true;
          }
          }





          share|improve this answer























          • No I don't want this Give me an allowed method . please
            – Silent Joker
            Aug 26 '15 at 15:14










          • So you mean I should use onPause() method . ok then just show me with codes
            – Silent Joker
            Aug 26 '15 at 16:29













          up vote
          1
          down vote










          up vote
          1
          down vote









          Note that according to the disallowed admob implementations:




          App load or exit



          Do not place interstitial ads on app load and when exiting apps as interstitials should only be placed in between pages of app content.




          Failure to adhere to this policy might lead to the disabling of ad-serving to your app.



          If you still want this, you can display in your onResume's method:



          boolean isAdShown;

          @Override
          protected void onResume() {
          super.onResume();
          if (!isAdShown) {
          displayInterstitial();
          isAdShown = true;
          }
          }





          share|improve this answer














          Note that according to the disallowed admob implementations:




          App load or exit



          Do not place interstitial ads on app load and when exiting apps as interstitials should only be placed in between pages of app content.




          Failure to adhere to this policy might lead to the disabling of ad-serving to your app.



          If you still want this, you can display in your onResume's method:



          boolean isAdShown;

          @Override
          protected void onResume() {
          super.onResume();
          if (!isAdShown) {
          displayInterstitial();
          isAdShown = true;
          }
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 26 '15 at 7:45









          Jared Rummler

          28.7k1392119




          28.7k1392119










          answered Aug 26 '15 at 7:30









          Nana Ghartey

          6,97811825




          6,97811825












          • No I don't want this Give me an allowed method . please
            – Silent Joker
            Aug 26 '15 at 15:14










          • So you mean I should use onPause() method . ok then just show me with codes
            – Silent Joker
            Aug 26 '15 at 16:29


















          • No I don't want this Give me an allowed method . please
            – Silent Joker
            Aug 26 '15 at 15:14










          • So you mean I should use onPause() method . ok then just show me with codes
            – Silent Joker
            Aug 26 '15 at 16:29
















          No I don't want this Give me an allowed method . please
          – Silent Joker
          Aug 26 '15 at 15:14




          No I don't want this Give me an allowed method . please
          – Silent Joker
          Aug 26 '15 at 15:14












          So you mean I should use onPause() method . ok then just show me with codes
          – Silent Joker
          Aug 26 '15 at 16:29




          So you mean I should use onPause() method . ok then just show me with codes
          – Silent Joker
          Aug 26 '15 at 16:29












          up vote
          -1
          down vote













          You should not place interstitial ads on app load and when exiting apps as However. You can show Interstitial after app load, with such practice you have to implement a splash screen in your app and show interstitial after it.




          An interstitial ad launches while the user is idle on the ‘Home
          Screen’ of the app. This implementation is in violation of our
          policies . One potential way to fix this violation, would be to
          implement a splash page that launches as the first screen of the app,
          before the ‘Home Screen’. The Interstitial ad should then launch in
          the transition between the splash screen and the ‘Home Screen’.




          Reference : -- > Google Blog






          share|improve this answer























          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
            – Eray Balkanli
            Nov 8 at 14:28










          • Couldn't agree more, just updated the answer, Thanks
            – Aegon
            Nov 8 at 20:42















          up vote
          -1
          down vote













          You should not place interstitial ads on app load and when exiting apps as However. You can show Interstitial after app load, with such practice you have to implement a splash screen in your app and show interstitial after it.




          An interstitial ad launches while the user is idle on the ‘Home
          Screen’ of the app. This implementation is in violation of our
          policies . One potential way to fix this violation, would be to
          implement a splash page that launches as the first screen of the app,
          before the ‘Home Screen’. The Interstitial ad should then launch in
          the transition between the splash screen and the ‘Home Screen’.




          Reference : -- > Google Blog






          share|improve this answer























          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
            – Eray Balkanli
            Nov 8 at 14:28










          • Couldn't agree more, just updated the answer, Thanks
            – Aegon
            Nov 8 at 20:42













          up vote
          -1
          down vote










          up vote
          -1
          down vote









          You should not place interstitial ads on app load and when exiting apps as However. You can show Interstitial after app load, with such practice you have to implement a splash screen in your app and show interstitial after it.




          An interstitial ad launches while the user is idle on the ‘Home
          Screen’ of the app. This implementation is in violation of our
          policies . One potential way to fix this violation, would be to
          implement a splash page that launches as the first screen of the app,
          before the ‘Home Screen’. The Interstitial ad should then launch in
          the transition between the splash screen and the ‘Home Screen’.




          Reference : -- > Google Blog






          share|improve this answer














          You should not place interstitial ads on app load and when exiting apps as However. You can show Interstitial after app load, with such practice you have to implement a splash screen in your app and show interstitial after it.




          An interstitial ad launches while the user is idle on the ‘Home
          Screen’ of the app. This implementation is in violation of our
          policies . One potential way to fix this violation, would be to
          implement a splash page that launches as the first screen of the app,
          before the ‘Home Screen’. The Interstitial ad should then launch in
          the transition between the splash screen and the ‘Home Screen’.




          Reference : -- > Google Blog







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 10 at 16:46

























          answered Nov 8 at 13:38









          Aegon

          393




          393












          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
            – Eray Balkanli
            Nov 8 at 14:28










          • Couldn't agree more, just updated the answer, Thanks
            – Aegon
            Nov 8 at 20:42


















          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
            – Eray Balkanli
            Nov 8 at 14:28










          • Couldn't agree more, just updated the answer, Thanks
            – Aegon
            Nov 8 at 20:42
















          While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
          – Eray Balkanli
          Nov 8 at 14:28




          While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
          – Eray Balkanli
          Nov 8 at 14:28












          Couldn't agree more, just updated the answer, Thanks
          – Aegon
          Nov 8 at 20:42




          Couldn't agree more, just updated the answer, Thanks
          – Aegon
          Nov 8 at 20:42


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32208974%2fhow-to-show-admob-interstitial-on-app-start%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          Bicuculline

          さくらももこ