# Channels for the Android SDK

Access and manage channel IDs, listen for channel creation, and configure the channel capture tool.

Each device or app install generates a unique identifier known as the Channel ID.
Once a Channel ID is created, it persists in the application until the app is
reinstalled or its internal data is cleared.

For information about finding Channel IDs, using the Channel Capture tool, and other methods to access Channel IDs, see [Finding Channel IDs](https://www.airship.com/docs/guides/getting-started/developers/identifiers/).

## Accessing the Airship Channel ID

Apps can access the Channel ID directly through the SDK.


#### Kotlin


```kotlin
val channelId = Airship.channel.id
```



#### Java


```java
String channelId = Airship.getChannel().getId();
```




The SDK creates the Channel ID asynchronously, so it may not be available immediately on the first run.
The SDK automatically batches and applies changes to Channel data when the Channel is created, so you do not need to wait for the Channel to be available before modifying data.

Applications that need to access the Channel ID can use a listener to receive notification when it becomes available.


#### Kotlin


Using `channelIdFlow` (StateFlow):

```kotlin
// channelIdFlow is a StateFlow<String?> that emits the channel ID when it's created
scope.launch {
    Airship.channel.channelIdFlow.collect { channelId ->
        channelId?.let {
            Log.d("Sample", "Channel created: $it")
        }
    }
}
```


Using `addChannelListener`:

```kotlin
Airship.channel.addChannelListener { channelId -> 
    Log.d("Sample", "Channel created: $channelId")
}
```



#### Java


Using `addChannelListener`:

```java
Airship.getChannel().addChannelListener(new AirshipChannelListener() {
    @Override
    public void onChannelCreated(@NonNull String channelId) {
        // created
    }
});
```




## Channel Capture tool

The Channel Capture tool is a feature built into the SDK that helps users find their Channel ID. For detailed information about how it works and how to use it, see [Finding Channel IDs](https://www.airship.com/docs/guides/getting-started/developers/identifiers/).

The Channel Capture tool can be disabled through the Airship Config options passed to `takeOff` during SDK initialization. For information about setting up the Airship SDK and configuring `AirshipConfigOptions`, see [Android SDK Setup](https://www.airship.com/docs/developer/sdk-integration/android/installation/getting-started/).


#### Kotlin


```kotlin
val options = airshipConfigOptions {
    // ...
    setChannelCaptureEnabled(false)
}
```



#### Java


```java
AirshipConfigOptions options = AirshipConfigOptions.newBuilder()
    // ...
    .setChannelCaptureEnabled(false)
    .build();
```




## Delaying channel creation

Airship creates the channel if at least one feature is enabled in the Privacy Manager.
To delay channel creation, use the Privacy Manager to disable all features during initialization.

For more information about Privacy Manager, see [Privacy Manager](https://www.airship.com/docs/developer/sdk-integration/android/data-collection/privacy-manager/).

