How To Set Up Timed Interstitials


#1

If you’re looking to show interstitials after a particular time period (rather than after certain activities), you can do the following:

  1. create a Handler as member of your activity
  2. onResume method should send DELAYED message to this handler.
  3. In handlemessage we show interstitial ad if ready. otherwise, we sends delayed message again.
  4. onPause we remove all possible messages from Handler.
    How it works.
    When Activity starts, on Resume method is called and delayed message is sent to handler.
    Thru a time this messsage is handled in Handler. If the ad is ready, we show it.
    In case of interstitial ad new activity is launched. So, onPause is called and removes all delayed messages from handler to avoid getting an ad showing once again (avoid to no overlay one ad by another one.)
    When user click to interstitial ad it closes and onResume is called once again. So we again have a trigger as delayed message in handler.