# Interstitial Ad

1. Create your `AdRequestConfiguration` as per the below format

```java
val configuration = AdRequestConfiguration.Companion.builder(context, "Your_placement_name");
```

{% tabs %}
{% tab title="Java" %}
{% code overflow="wrap" %}

```java
AdRequestConfiguration.Builder configuration = AdRequestConfiguration.Companion.builder(context, "Your_placement_name");
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code overflow="wrap" %}

```kotlin
val configuration = AdRequestConfiguration.builder(context, "Your_placement_name")
```

{% endcode %}
{% endtab %}
{% endtabs %}

2. Call `loadAd()` method as per below format

{% tabs %}
{% tab title="Java" %}

```java
AdSterAdLoader.Companion.builder().withAdsListener(new MediationAdListener(){
    @Override
    public void onInterstitialAdLoaded(@NonNull MediationInterstitialAd ad) {
        super.onInterstitialAdLoaded(ad);
        //Show interstitial ad here
    }

    @Override
    public void onFailure(@NonNull AdError adError) {
        //Handle failure callback here
    }
}).withInterstitialAdEventsListener(new InterstitialAdEventsListener() {
    @Override
    public void onAdClicked() {
        //Handle ad click here
    }

    @Override
    public void onAdImpression() {
        //Handle ad impression here
    }

    @Override
    public void onAdOpened() {
        //Handle ad open here
    }

    @Override
    public void onAdClosed() {
        //Handle ad closed here
    }
    
    @Override
    public void onAdRevenuePaid(double revenue, @NotNull String adUnitId,@NotNull String network, @NotNull String currency, @NotNull PrecisionType precisionType) {
        // Callback which provides revenue and the network which provided it
    }
}).build().loadAd(configuration.build());
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
AdSterAdLoader.builder().withAdsListener(object : MediationAdListener() {
    override fun onInterstitialAdLoaded(ad: MediationInterstitialAd) {
        super.onInterstitialAdLoaded(ad)
        //Show interstitial ad here
    }

    override fun onFailure(adError: AdError) {
        //Handle failure callback here
    }
}).withInterstitialAdEventsListener(object : InterstitialAdEventsListener() {
    override fun onAdClicked() {
        //Handle ad click here
    }
    
    override fun onAdImpression() {
        //Handle ad impression here
    }
    
    override fun onAdOpened() {
        //Handle ad open here
    }
    
    override fun onAdClosed() {
        //Handle ad close here
    }
    
    override fun onAdRevenuePaid(revenue: Double, adUnitId: String, network: String, currency: String, precisionType: PrecisionType) {
        // Callback which provides revenue and the network which provided it
    }
}).build().loadAd(configuration.build())
```

{% endtab %}
{% endtabs %}

3. Inside the `onInterstitialAdLoaded` callback method invoke `showAd(activity)` method of `MediationInterstitialAd` object to show AdSter interstitial ad above any activity as shown below

{% tabs %}
{% tab title="Java" %}

<pre class="language-java"><code class="lang-java"><strong>@Override
</strong>public void onInterstitialAdLoaded(@NonNull MediationInterstitialAd ad) {
     super.onInterstitialAdLoaded(ad);
     ad.showAd(getApplicationContext());
  }

</code></pre>

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
override fun onInterstitialAdLoaded (ad: MediationInterstitialAd) {
    super.onInterstitialAdLoaded (ad)
    ad.showAd(activity);
}
```

{% endtab %}
{% endtabs %}

4. Make sure to pass only Activity\`s context as parameter to `showAd()`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.adster.tech/how-to-render-an-ad/interstitial-ad.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
