# Delegate Methods

## Overview

The Chartboost SDK's delegate methods allow you to exercise greater control over your integration. For example, you can:

- Log debug messages when your game attempts to load an interstitial.
- Prevent ads from showing the first time a user plays your game.
- Determine whether or not a user has clicked an ad or closed it and react accordingly.
- Prevent an interstitial page from appearing when and where it would interfere with your game.

You can view the Chartboost Android SDK methods in the documentation in the doc folder included with your [Android SDK download](/en/monetization/get-started/#sdk-integration). You can see many of these methods in use in the sample project included in the package. SDK configuration methods

[View Android configuration methods](/en/monetization/integrate/android/sdk-privacy-methods/). 



## Ad Identifier

Error objects (such as `CacheError`, `ShowError`, or `ClickError`) passed as parameters in delegate method calls may include additional error information. All non-error event objects include an `adID` property.

This is a string that uniquely identifies a cached ad. It might help when working with Chartboost to identify faulty creatives.



## onAdExpired

`onAdExpired(event: ExpirationEvent)` is an optional callback (it has a default empty implementation) that fires when a previously cached ad expires or is removed from the cache. Implement this method if you want to be notified so you can trigger a new cache request.

The `ExpirationEvent` carries:
- `ad` — the `Ad` object that expired.
- `reason` — an `ExpirationReason` enum value explaining why:

| Value | Description |
| ----- | ----------- |
| `TTL_EXPIRED` | The ad's Time-To-Live elapsed. |
| `SIZE_LIMIT_EVICTION` | The ad was evicted to make space due to cache size limits (LRU policy). |
| `EXPLICIT_EVICTION` | The ad was explicitly removed via an `evict()` call. |
| `CACHE_CLEARED` | The entire cache was cleared. |
| `UNKNOWN` | The reason could not be determined. |

<ul class="tab" data-tab="6001ce1b-58d9-4e31-b2f2-aa586ab3118e" data-name="onAdExpiredCallback">
  
      <li class="active">
          <a href="#">Kotlin </a>
      </li>
  
      <li>
          <a href="#">Java </a>
      </li>
  
</ul>
<ul class="tab-content" id="6001ce1b-58d9-4e31-b2f2-aa586ab3118e" data-name="onAdExpiredCallback">
  
      <li class="active">
<div class="language-kotlin highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">override</span> <span class="k">fun</span> <span class="nf">onAdExpired</span><span class="p">(</span><span class="n">expirationEvent</span><span class="p">:</span> <span class="nc">ExpirationEvent</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// Re-cache the ad if needed</span>
    <span class="n">expirationEvent</span><span class="p">.</span><span class="n">ad</span><span class="p">.</span><span class="nf">cache</span><span class="p">()</span>
<span class="p">}</span>
</code></pre></div></div>
</li>
  
      <li>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nd">@Override</span>
<span class="kd">public</span> <span class="kt">void</span> <span class="nf">onAdExpired</span><span class="o">(</span><span class="nd">@NonNull</span> <span class="nc">ExpirationEvent</span> <span class="n">expirationEvent</span><span class="o">)</span> <span class="o">{</span>
    <span class="c1">// Re-cache the ad if needed</span>
    <span class="n">expirationEvent</span><span class="o">.</span><span class="na">getAd</span><span class="o">().</span><span class="na">cache</span><span class="o">();</span>
<span class="o">}</span>
</code></pre></div></div>
</li>
  
</ul>


