Class InterstitialBuilder

java.lang.Object
com.appbrain.InterstitialBuilder

public class InterstitialBuilder extends Object
Convenience class used to configure and show interstitials. Its methods can be chained together, e.g.:
InterstitialBuilder.create().setAdId(AdId.EXIT).setFinishOnExit(this).show(this)
  • Method Details

    • create

      public static InterstitialBuilder create()
    • create

      public static InterstitialBuilder create(AdOptions options)
    • setAdId

      public InterstitialBuilder setAdId(AdId adId)
      Set the AdId for this interstitial, used to track different interstitials in your app.
    • getAdId

      public AdId getAdId()
      Returns:
      The current AdId set by setAdId(AdId).
    • setListener

      public InterstitialBuilder setListener(InterstitialListener listener)
      Set a listener for open, close and click events of the interstitial.
    • getListener

      public InterstitialListener getListener()
      Returns:
      The current InterstitialListener set by setListener(InterstitialListener).
    • setOnDoneCallback

      public InterstitialBuilder setOnDoneCallback(Runnable onDoneCallback)
      Set a callback for when the interstitial is done. This is a convenient way to execute certain logic after the interstitial. The callback will be called either when the interstitial is closed, or when the interstitial is not opened (e.g. when maybeShow(Context) returns false).
    • getOnDoneCallback

      public Runnable getOnDoneCallback()
      Returns:
      The current callback set by setOnDoneCallback(Runnable).
    • setScreenType

      public InterstitialBuilder setScreenType(AdOptions.ScreenType screenType)
      Set whether to show the interstitial and offerwall in full screen or as a dialog. The default is ScreenType.DIALOG. Note that a dialog is only used when opening the interstitial from an Activity that is not finishing.
    • getScreenType

      public AdOptions.ScreenType getScreenType()
      Returns:
      The current AdOptions.ScreenType set by setScreenType(ScreenType).
    • setAnalyticsString

      public InterstitialBuilder setAnalyticsString(String analyticsString)
      Set a custom string to pass on to the AppBrain servers for analytics purposes.
    • getAnalyticsString

      public String getAnalyticsString()
      Returns:
      The current analytics string set by setAnalyticsString(String).
    • setFinishOnExit

      public InterstitialBuilder setFinishOnExit(Activity activity)
      Finish this Activity when the interstitial is closed. This sets the InterstitialListener internally, so can not be used in combination with setListener(InterstitialListener).
    • setAllowedToUseMediation

      public InterstitialBuilder setAllowedToUseMediation(boolean allowedToUseMediation)
      Set to false to make sure this interstitial will not use mediation, even if mediation is enabled for its AdId. Default value is true.
    • preload

      public InterstitialBuilder preload(Context context)
      Loads an interstitial, which can then later be shown using show(Context) or maybeShow(Context). Note that if you want to use AppBrain mediation, preload() must be called before showing. If you don't use mediation, preload() is optional.
    • show

      public boolean show(Context context)
      Shows the interstitial if there is an internet connection.
      Parameters:
      context - the current Context
      Returns:
      true if the interstitial was shown
    • maybeShow

      public boolean maybeShow(Context context)
      Shows an interstitial at certain times. Our algorithm determines the frequency optimized for the highest click through rate. The interstitial is only shown when there is an internet connection.
      Parameters:
      context - the current Context
      Returns:
      true if the interstitial was shown