Interstitial Ads
This guide shows how to display Interstitial Ads in your application.
What are Interstitial Ads?
How to Display Interstitial Ads
Integrate & Initialize HyprMX
Loading Interstitial Ads
1
interstitialPlacement = HyprMX.INSTANCE.getPlacement("YOUR_INTERSTITIAL_PLACEMENT_NAME");interstitialPlacement = HyprMX.getPlacement("YOUR_INTERSTITIAL_PLACEMENT_NAME")2
interstitialPlacement.loadAd(new HyprMXLoadAdListener() {
@Override
public void onAdLoaded(boolean isAdAvailable) {
if(isAdAvailable) {
// You can show the ad
}
}
});interstitialPlacement.loadAd(isAdAvailable -> {
if(isAdAvailable) {
// You can show the ad
}
});interstitialPlacement.loadAd { isAdAvailable ->
if(isAdAvailable) {
// You can show the ad
}
}val isAdAvailable = interstitialPlacement.loadAd()
if(isAdAvailable) {
// You can show the ad
}3
private HyprMXPlacementExpiryListener listener = new HyprMXPlacementExpiryListener() {
@Override
public void onAdExpired(@NonNull Placement placement) {
// Do something on expiration
}
}
interstitialPlacement.setPlacementExpiryListener(listener);interstitialPlacement.setPlacementExpiryListener(placement -> {
// Do something on expiration
});val listener = object : HyprMXPlacementExpiryListener {
override fun onAdExpired(placement: Placement) {
// Do something on expiration
}
}
interstitialPlacement.setPlacementExpiryListener(listener)Displaying Interstitial Ads
1
interstitialPlacement.isAdAvailable();interstitialPlacement.isAdAvailable()2
if (interstitialPlacement.isAdAvailable()) {
interstitialPlacement.showAd(this);
}if (interstitialPlacement.isAdAvailable()) {
interstitialPlacement.showAd(this)
}3
/**
* Called when an ad is shown for the given placement. Your application should pause here.
*/
@Override
public void onAdStarted(Placement placement) {}
/**
* Called when an ad is closed. Your application should resume here.
*/
@Override
public void onAdClosed(Placement placement, boolean finished) {}
/**
* Called when there was an error displaying the ad.
*/
@Override
public void onAdDisplayError(Placement placement, HyprMXErrors hyprMXError) {}
/**
* Called when the ad was impressed.
*/
@Override
public void onAdImpression(Placement placement) {}Last updated
