SDK Documentation
HomeBlogSign up
English
English
  • 🏠Homepage
  • 🧪Test Ad Units
  • Privacy
    • ✅Google Data Safety
  • Android SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
    • 🛠️ProGuard
  • iOS SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Revenue reporting
    • 🙍User consent
    • 🔓Privacy
  • Unity SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • Flutter SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • React Native
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • Web SDK
    • ⌨️SDK integration
Con tecnología de GitBook
En esta página
  • Integration
  • Listener configuration
  1. Android SDK
  2. SDK integration

Interstitial

Integration

Unlike banners, interstitials can only be integrated with code. Below we show a simple example to understand how it works:

class MainActivity : Activity() {

    private var interstitialAd: InterstitialAd? = null
    
    override fun onCreate(savedInstanceState: Bundle?) {
        ...
        interstitialAd = InterstitialAd(this, "<Wortise Ad Unit ID>").also {
	          it.loadAd()
        }
    }
    
    override fun onDestroy() {
        ...
        interstitialAd?.destroy()
    }
    
    fun showInterstitial() {
        if (interstitialAd?.isAvailable == true) {
            interstitialAd?.showAd(this)
        }
    }
}
public class MainActivity extends Activity {

    private InterstitialAd mInterstitial;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        ...
        mInterstitial = new InterstitialAd(this, "Wortise Ad Unit ID");
        mInterstitial.loadAd();
    }
    
    @Override
    public void onDestroy() {
        ...
        mInterstitial.destroy();
    }
    
    public void showInterstitial() {
        if (mInterstitial.isAvailable()) {
            mInterstitial.showAd(this);
        }
    }
}

Listener configuration

Like occurs with banners, a listener can be set to receive the events that happen during the interstitial lifecycle. For this, it is needed to implement the InterstitialAd.Listener interface just as shown in the example below:

interstitialAd.listener = object : InterstitialAd.Listener() {

    override fun onInterstitialClicked(ad: InterstitialAd) {
        // Invoked when the ad has been clicked
    }
    
    override fun onInterstitialDismissed(ad: InterstitialAd) {
        // Invoked when the ad has been dismissed
    }
    
    override fun onInterstitialFailedToLoad(ad: InterstitialAd,
                                            error: AdError) {
        // Invoked when the ad could not be loaded
        // (because of an error or no fill)
    }

    override fun onInterstitialFailedToShow(ad: InterstitialAd,
                                            error: AdError) {
        // Invoked when the ad could not be shown
    }
    
    override fun onInterstitialImpression(ad: InterstitialAd) {
        // Invoked when the ad has generated an impression
    }
    
    override fun onInterstitialLoaded(ad: InterstitialAd) {
        // Invoked when the ad has been loaded
    }
    
    override fun onInterstitialRevenuePaid(ad: InterstitialAd,
                                           data: RevenueData) {
        // Invoked when the ad has generated revenue
    }
    
    override fun onInterstitialShown(ad: InterstitialAd) {
        // Invoked when the ad has been shown
    }
}
mInterstitial.setListener(new InterstitialAd.Listener() {
    @Override
    public void onInterstitialClicked(@NonNull InterstitialAd ad) {
        // Invoked when the ad has been clicked
    }
    
    @Override
    public void onInterstitialDismissed(@NonNull InterstitialAd ad) {
        // Invoked when the ad has been dismissed
    }
    
    @Override
    public void onInterstitialFailedToLoad(@NonNull InterstitialAd ad,
                                           @NonNull AdError error) {
        // Invoked when the ad could not be loaded
        // (because of an error or no fill)
    }

    @Override
    public void onInterstitialFailedToShow(@NonNull InterstitialAd ad,
                                           @NonNull AdError error) {
        // Invoked when the ad could not be shown
    }
    
    @Override
    public void onInterstitialImpression(@NonNull InterstitialAd ad) {
        // Invoked when the ad has generated an impression
    }
    
    @Override
    public void onInterstitialLoaded(@NonNull InterstitialAd ad) {
        // Invoked when the ad has been loaded
    }
    
    @Override
    public void onInterstitialRevenuePaid(@NonNull InterstitialAd ad,
                                          @NonNull RevenueData data) {
        // Invoked when the ad has generated revenue
    }
    
    @Override
    public void onInterstitialShown(@NonNull InterstitialAd ad) {
        // Invoked when the ad has been shown
    }
});
AnteriorBannerSiguienteRewarded

Última actualización hace 3 días

⌨️