---
title: Configure event dispatcher for the Android SDK
slug: feature-experimentation/docs/configure-event-dispatcher-android
docTags: 
createdAt: 2026-08-05T20:39:54.000Z
---

The Optimizely Feature Experimentation SDKs make HTTP requests for every [decision event or conversion event](docId\:SzVcfUMHk3IKycnEjgjbq) that gets triggered. Each SDK has a built-in **event dispatcher** for handling these events, but you should overriding it based on the specifics of your environment.

The Android SDK has an out-of-the-box asynchronous dispatcher. You should customizing the event dispatcher you use in production to ensure that you queue and send events in a manner that scales to the volumes handled by your application. Customizing the event dispatcher lets you take advantage of features like batching, which makes it easier to handle large event volumes efficiently or to implement retry logic when a request fails. You can build your dispatcher from scratch or start with the provided dispatcher.

The examples show that to customize the event dispatcher, initialize the Optimizely client (or manager) with an event dispatcher instance.

```kotlin
// Using an anonymous class here to implement the EventHandler interface.
// Feel free to create an explicit class that implements the interface instead.
val eventHandler = object : EventHandler {
   override fun dispatchEvent(logEvent: LogEvent) {
      // Send event to our log endpoint as documented in
      // https://docs.developers.optimizely.com/experimentation-data/docs/send-events-overview
   }
}

// Build a manager
val optimizelyManager = OptimizelyManager.builder()
          .withSDKKey("SDK_KEY_HERE")
          .withEventDispatchInterval(60, TimeUnit.SECONDS)
          .withEventHandler(eventHandler)
          .build(context)
```

```java
// Using an anonymous class here to implement the EventHandler interface.
// Feel free to create an explicit class that implements the interface instead.
EventHandler eventHandler = new EventHandler() {
   @Override
   public void dispatchEvent(LogEvent logEvent) throws Exception {
      // Send event to our log endpoint as documented in 
      // https://docs.developers.optimizely.com/experimentation-data/docs/send-events-overview
   }
};

// Build a manager
OptimizelyManager optimizelyManager = OptimizelyManager.builder()
       .withSDKKey("SDK_KEY_HERE")
       .withEventDispatchInterval(60, TimeUnit.SECONDS)
       .withEventHandler(eventHandler)
       .build(context);
```

The event dispatcher should implement a `dispatchEvent` function, which takes in a `LogEvent` argument created by the internal `EventFactory` class. In this function, you should send a `POST` request to the given endpoint URL using the event payload as the body of the request (be sure to stringify it to JSON) and `{content-type: 'application/json'}` in the headers.

:::hint{type="warning"}
**Important**
If you are using a custom event dispatcher, do not modify the event payload returned from Optimizely. Modifying this payload will alter your results.
:::

The included event handler implementation includes queueing and flushing, so it works even if an app is offline. The event handler stores events in a SQLite database and uses WorkManager to dispatch them. WorkManager runs dispatch only when a network connection is available and automatically retries failed requests. The SDK's library manifest also reschedules pending dispatches after a device reboot or app update, so you do not need to add any receivers or intent filters to your AndroidManifest.xml.

You will need to implement [EventHandler](https://github.com/optimizely/java-sdk/blob/master/core-api/src/main/java/com/optimizely/ab/event/EventHandler.java) to use your own event handler.
