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_INTERSTITIALImplementation Steps
Interstitial ads are implemented in 4 steps:- Initialize - Create AdropInterstitialAd instance
- Set Listener - Configure listener for ad events
- Load Ad - Request and receive ads
- Show Ad - Display the ad on screen
Basic Implementation
Creating AdropInterstitialAd Instance
AdropInterstitialAd Constructor
Android Context object (Activity or Application Context)
Ad unit ID (issued from console)
Setting Listener
To receive ad events, implement and setAdropInterstitialAdListener.
Loading Ad
Call theload() method to request an ad.
onAdReceived callback is called when the ad is successfully loaded, and onAdFailedToReceive is called when loading fails.
Showing Ad
Call theshow() 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 callingshow().
show Method
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
Called when ad is successfully received. You can call
show() to display the ad from this point.Called when ad fails to load. Check the error code for the failure reason.
Optional Methods
Called when an ad impression is recorded.
Called when the user clicks the ad.
Called just before the interstitial ad is displayed. You can pause game logic here.
Called immediately after the interstitial ad is displayed on screen.
Called just before the interstitial ad is closed.
Called immediately after the interstitial ad is closed. Good time to preload the next ad.
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 settingAdropInterstitialAdCloseListener.
AdropInterstitialAdCloseListener
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 calldestroy() to release resources when the Activity or Fragment is destroyed.
Preloading Strategy
It’s recommended to preload ads for better user experience.Basic Preloading
Reload After Dismiss
Preload the next ad in theonAdDidDismissFullScreen 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
onAdReceived is not called
onAdReceived is not called
- Verify SDK is initialized
- Check unit ID is correct
- Check network connection
- Verify AndroidManifest.xml has internet permission
onAdFailedToReceive is called
onAdFailedToReceive is called
- Check the error code to identify the issue
ERROR_CODE_AD_NO_FILL: No ad inventory, try again laterERROR_CODE_NETWORK: Check network connectionERROR_CODE_INVALID_UNIT: Verify unit ID
Nothing happens after show() is called
Nothing happens after show() is called
- Ensure
show()is called afteronAdReceivedcallback - Check
isLoadedproperty istrue - Verify Activity is valid
- Ensure another interstitial ad is not already showing
Memory leak warning
Memory leak warning
- Verify
destroy()is called inonDestroy() - 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 theisBackfilled 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