
The Kotlin Android SDK lets you send events to Amplitude.

## Configure the SDK

{% accordion title="Configuration Options" %}
| Name | Description | Default Value |
| --- | --- | --- |
| `deviceId` | `String?`. The device ID to use for this device. If you don't provide a device ID, the SDK generates one automatically. | `null` |
| `flushIntervalMillis` | `Int`. The amount of time the SDK waits before it uploads unsent events to the server or reaches the `flushQueueSize` threshold. The value is in milliseconds. | `30000` |
| `flushQueueSize` | `Int`. The SDK uploads events when the unsent event count exceeds this threshold or when it reaches the `flushIntervalMillis` interval. | `30` |
| `flushMaxRetries` | `Int`. Maximum retry times. | `5` |
| `minIdLength` | `Int`. The minimum length for user id or device id. | `5` |
| `partnerId` | `Int`. The partner id for partner integration. | `null` |
| `identifyBatchIntervalMillis` | `Long`. The amount of time the SDK batches intercepted identify events. The value is in milliseconds. | `30000` |
| `flushEventsOnClose` | `Boolean`. Flushing of unsent events on app close. | `true` |
| `callback` | `EventCallBack`. Callback function after event sent. | `null` |
| `optOut` | `Boolean`. Opt the user out of tracking. | `false` |
| `trackingSessionEvents` | `Boolean`. Deprecated. Automatic tracking of "Start Session" and "End Session" events that count toward event volume. | `false` |
| `defaultTracking` | `DefaultTrackingOptions`. Options to control the default events tracking. | Refer to [Tracking default events](#tracking-default-events) |
| `minTimeBetweenSessionsMillis` | `Long`. The amount of time for session timeout. The value is in milliseconds. | `300000` |
| `serverUrl` | `String`. The server url events upload to. | `https://api2.amplitude.com/2/httpapi` |
| `serverZone` | `ServerZone.US` or `ServerZone.EU`. The server zone to send to. The SDK adjusts the server URL based on this configuration. | `ServerZone.US` |
| `useBatch` | `Boolean` Whether to use batch api. | `false` |
| `useAdvertisingIdForDeviceId` | `Boolean`. Whether to use advertising id as device id. For the required module and permission, refer to the [advertiser ID documentation](/docs/sdks/analytics/android/android-kotlin-sdk#advertiser-id). | `false` |
| `useAppSetIdForDeviceId` | `Boolean`. Whether to use app set id as device id. For the required module and permission, refer to the [app set ID documentation](/docs/sdks/analytics/android/android-kotlin-sdk#app-set-id). | `false` |
| `trackingOptions` | `TrackingOptions`. Options to control the values tracked in SDK. | `enable` |
| `enableCoppaControl` | `Boolean`. Whether to enable COPPA control for tracking options. | `false` |
| `instanceName` | `String`. The name of the instance. Instances with the same name share storage and identity. For isolated storage and identity, use a unique `instanceName` for each instance. | `$default_instance` |
| `migrateLegacyData` | `Boolean`. Available in `1.9.0`+. Whether to migrate [maintenance Android SDK](/docs/sdks/analytics/android/android-sdk) data (events, user/device ID). For more information, refer to [`RemnantDataMigration.kt`](https://github.com/amplitude/Amplitude-Kotlin/blob/main/android/src/main/java/com/amplitude/android/migration/RemnantDataMigration.kt#L9-L16). | `true` |
| `offline` | `Boolean | AndroidNetworkConnectivityCheckerPlugin.Disabled`. Whether the SDK has a network connection. | `false` |
| `storageProvider` | `StorageProvider`. Implements `StorageProvider` interface to store events. | `AndroidStorageProvider` |
| `identifyInterceptStorageProvider` | `StorageProvider`. Implements `StorageProvider` interface for identify event interception and volume optimization. | `AndroidStorageProvider` |
| `identityStorageProvider` | `IdentityStorageProvider`. Implements `IdentityStorageProvider` to store user id and device id. | `FileIdentityStorageProvider` |
| `loggerProvider` | `LoggerProvider`. Implements `LoggerProvider` interface to emit log messages to your chosen destination. | `AndroidLoggerProvider` |
| `newDeviceIdPerInstall` | Whether to generate a different device id on each app install, regardless of device. This is a legacy configuration that maintains compatibility with the old Android SDK. It works the same as `useAdvertisingIdForDeviceId`. | `false` |
| `locationListening` | Whether to enable Android location service. | `true` |

{% /accordion %}

### Configure batching behavior

To support high-performance environments, the SDK sends events in batches. The SDK queues every event that the `track` method logs in memory, then flushes events in batches in the background. To customize batch behavior, set `flushQueueSize` and `flushIntervalMillis`. By default, `serverUrl` is `https://api2.amplitude.com/2/httpapi`. To send large batches of data at a time, set `useBatch` to `true`. Setting `useBatch` to `true` directs `setServerUrl` to the batch event upload API at `https://api2.amplitude.com/batch`. Both regular mode and batch mode use the same event upload threshold and flush time intervals.

{% code-group %}
```kotlin Kotlin
import com.amplitude.android.Amplitude

val amplitude = Amplitude(
 Configuration(
 apiKey = AMPLITUDE_API_KEY,
 context = applicationContext,
 flushIntervalMillis = 50000,
 flushQueueSize = 20,
 )
)
```

```java Java
import com.amplitude.android.Amplitude;

Configuration configuration = new Configuration(AMPLITUDE_API_KEY, getApplicationContext());
configuration.setFlushIntervalMillis(1000);
configuration.setFlushQueueSize(10);

Amplitude amplitude = new Amplitude(configuration);
```
{% /code-group %}
