InterstitialBuilder
- public class InterstitialBuilder
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)
- Author
AppBrain
Methods
- public static InterstitialBuilder create()
- public AdId getAdId()
- Returns
The current
AdId
set bysetAdId(AdId)
.
- public InterstitialListener getListener()
- Returns
The current
InterstitialListener
set bysetListener(InterstitialListener)
.
- public Runnable getOnDoneCallback()
- Returns
The current callback set by
setOnDoneCallback(Runnable)
.
- public ScreenType getScreenType()
- Returns
The current
ScreenType
set bysetScreenType(ScreenType)
.
- 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
- public InterstitialBuilder preload(Context context)
Loads an interstitial, which can then later be shown using
show(Context)
ormaybeShow(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.
- public InterstitialBuilder setAdId(AdId adId)
Set the
AdId
for this interstitial, used to track different interstitials in your app.
- 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.
- 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 withsetListener(InterstitialListener)
.
- public InterstitialBuilder setListener(InterstitialListener listener)
Set a listener for open, close and click events of the interstitial.
- 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).
- public InterstitialBuilder setScreenType(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.
- 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
- boolean showWithSkipChange(Context context, double skipChance)