Skip to main content

Overview

Interstitial ads are full-screen ads that cover the entire interface of the app. They are best suited for natural transition points in the app, such as game level transitions or content page changes.

Features

  • Full-screen immersive ads
  • Remain visible until explicitly closed by the user
  • Support for image and video ads
  • High visual attention
Use the test unit ID for development: PUBLIC_TEST_UNIT_ID_INTERSTITIAL

Implementation Steps

Interstitial ads are implemented in 4 steps:
  1. Initialize - Create AdropInterstitialAd instance
  2. Set Listener - Configure listener for ad events
  3. Load Ad - Request and receive ads
  4. Show Ad - Display the ad on screen

Basic Implementation

Creating AdropInterstitialAd Instance

AdropInterstitialAd Constructor

Context
required
Android Context object (Activity or Application Context)
String
required
Ad unit ID (issued from console)

Setting Listener

To receive ad events, implement and set AdropInterstitialAdListener.

Loading Ad

Call the load() method to request an ad.
The onAdReceived callback is called when the ad is successfully loaded, and onAdFailedToReceive is called when loading fails.

Showing Ad

Call the show() method to display the ad after it’s loaded.

isLoaded Property

A property to check if the ad is loaded. It’s recommended to check this value before calling show().

show Method

Activity
required
Activity object to display the ad

AdropInterstitialAd Properties

unitId

Returns the ad unit ID.

isLoaded

Returns whether the ad is loaded.

creativeId

Returns the creative ID of the currently loaded ad.

txId

Returns the transaction ID of the currently loaded ad.

campaignId

Returns the campaign ID of the currently loaded ad.

isBackfilled

Returns whether the currently loaded ad is a backfill ad.

close()

Programmatically closes the interstitial ad.

AdropInterstitialAdListener Methods

Required Methods

(AdropInterstitialAd) -> Unit
Called when ad is successfully received. You can call show() to display the ad from this point.
(AdropInterstitialAd, AdropErrorCode) -> Unit
Called when ad fails to load. Check the error code for the failure reason.

Optional Methods

(AdropInterstitialAd) -> Unit
Called when an ad impression is recorded.
(AdropInterstitialAd) -> Unit
Called when the user clicks the ad.
(AdropInterstitialAd) -> Unit
Called just before the interstitial ad is displayed. You can pause game logic here.
(AdropInterstitialAd) -> Unit
Called immediately after the interstitial ad is displayed on screen.
(AdropInterstitialAd) -> Unit
Called just before the interstitial ad is closed.
(AdropInterstitialAd) -> Unit
Called immediately after the interstitial ad is closed. Good time to preload the next ad.
(AdropInterstitialAd, AdropErrorCode) -> Unit
Called when ad fails to show. Check the error code for the failure reason.

Back Button Callback

You can receive a callback when the user presses the back button while an interstitial ad is displayed by setting AdropInterstitialAdCloseListener.

AdropInterstitialAdCloseListener

(AdropInterstitialAd) -> Unit
Called when the user presses the back button while the interstitial ad is displayed.

Usage

Behavior

  • Back button callback: When the user presses the back button, closeListener.onBackPressed() is called first.
  • Auto-close condition: If more than 30 seconds have passed since the ad was displayed, or if there is no WebView, the ad is automatically closed when the back button is pressed.
  • Manual close: You can programmatically close the ad at any time by calling ad.close().
  • If closeListener is not set: The existing behavior is maintained (auto-close after 30 seconds only).

Android 15+ Compatibility

On Android 13 (Tiramisu) and above, OnBackInvokedCallback is used to support Predictive Back. It works correctly even if your app has enableOnBackInvokedCallback="true" set.

Lifecycle Management

destroy Method

You must call destroy() to release resources when the Activity or Fragment is destroyed.
Always call destroy() to prevent memory leaks.

Preloading Strategy

It’s recommended to preload ads for better user experience.

Basic Preloading

Reload After Dismiss

Preload the next ad in the onAdDidDismissFullScreen callback after the ad is closed.

Best Practices

1. Appropriate Display Timing

Show ads at natural transition points in the app.

2. Error Handling

Implement handling for ad load failures.

3. Frequency Capping

Don’t show ads too frequently.

4. Game Pause Handling

Pause games or animations when showing interstitial ads.

Testing

Using Test Unit ID

Use test unit IDs during development.

Verify Ad Load

Verify that ads are loading correctly.

Complete Implementation Example


Troubleshooting

  • Verify SDK is initialized
  • Check unit ID is correct
  • Check network connection
  • Verify AndroidManifest.xml has internet permission
  • Check the error code to identify the issue
  • ERROR_CODE_AD_NO_FILL: No ad inventory, try again later
  • ERROR_CODE_NETWORK: Check network connection
  • ERROR_CODE_INVALID_UNIT: Verify unit ID
  • Ensure show() is called after onAdReceived callback
  • Check isLoaded property is true
  • Verify Activity is valid
  • Ensure another interstitial ad is not already showing
  • Verify destroy() is called in onDestroy()
  • Check Context reference is managed with WeakReference
  • Ensure listener is set to null

Backfill Ads

When backfill ads are enabled, backfill ads are automatically loaded when direct ads are unavailable. Use the isBackfilled property to check if the ad is a backfill ad.
To use backfill ads, add the io.adrop:adrop-ads-backfill dependency. See Getting Started.

Next Steps

Rewarded Ads

Improve user engagement with rewarded ads

Banner Ads

Implement banner ads

Targeting Settings

User properties and contextual targeting

Reference

API reference documentation