Follow

Advanced Usage - Adding Interstitial Callbacks

View original article on our GitHub

Adding a Callback when an Interstitial Ad is loaded

startAppAd.loadAd() can be called before showing the ad, and get an implementation ofAdEventListener as a parameter. To get a callback when an Ad is loaded, pass the object that implements AdEventListener (this may be your Activity) as a parameter to the loadAd method. This object must implement the following methods:

@Override
public void onReceiveAd(Ad ad) {
}
@Override
public void onFailedToReceiveAd(Ad ad) {
}

Example

startAppAd.loadAd (new AdEventListener() {
    @Override
    public void onReceiveAd(Ad ad) {
    }
    @Override
    public void onFailedToReceiveAd(Ad ad) {
    }
});

IMPORTANT: Do not call loadAd() from within onFailedToReceiveAd(). The SDK will automatically try to reload an ad upon a failure.

Adding a Callback when an Interstitial Ad is shown

startAppAd.showAd() can get a parameter implementation of AdDisplayListener. To get a callback when an Ad is shown, pass the object that implements AdDisplayListener (this may be your Activity) as a parameter of the method. This object must implement the following methods:

@Override
public void adHidden(Ad ad) {
}

@Override
public void adDisplayed(Ad ad) {
}

@Override
public void adClicked(Ad ad) {
}

@Override
public void adNotDisplayed(Ad ad) {
}

Example

startAppAd.showAd(new AdDisplayListener() {
    @Override
    public void adHidden(Ad ad) {
    }
    @Override
    public void adDisplayed(Ad ad) {
    }
    @Override
    public void adClicked(Ad ad) {
    }
    @Override
    public void adNotDisplayed(Ad ad) {
    }
});
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments