---
source_url: https://www.pubnub.com/docs/sdks/android/api-reference/channel-groups
title: Channel Groups API for Android SDK
updated_at: 2026-05-25T05:45:10.038Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Channel Groups API for Android SDK

:::warning Unsupported docs
PubNub no longer maintains Android SDK docs, but our [Java SDK](https://www.pubnub.com/docs/sdks/java) or [Kotlin SDK](https://www.pubnub.com/docs/sdks/kotlin) are fully compatible with the Android platform and you can use them to build mobile apps, ensuring stable software development.
:::

[Channel groups](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups) allow PubNub developers to bundle thousands of [channels](https://www.pubnub.com/docs/general/channels/overview) into a group that can be identified by a name. These channel groups can then be subscribed to, receiving data from the many back-end channels the channel group contains.

:::note Channel group operations
You can't publish to a channel group. You can only subscribe to it. To publish within the channel group, you need to publish to each channel individually.
:::

## Add channels to a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the PubNub [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function adds channels to a channel group.

### Method(s)

Use the following method in the Android SDK:

:::note Maximum number of channels
You can add up to 200 channels to a channel group per API call.
:::

```java
this.pubnub.addChannelsToChannelGroup()
    .channelGroup(String)
    .channels(Array)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channelGroup | String | Yes |  | The channel group to add the channels to. |
| channels | Array | Yes |  | The channels to add to the channel group. |
| async | PNCallback | Yes |  | `PNCallback` of type `PNChannelGroupsAddChannelResult` |

### Sample code

#### Add channels

```java
pubnub.addChannelsToChannelGroup()
    .channelGroup("cg1")
    .channels(Arrays.asList("ch1", "ch2", "ch3"))
    .async(new PNCallback<PNChannelGroupsAddChannelResult>() {
        @Override
        public void onResponse(PNChannelGroupsAddChannelResult result, PNStatus status) {

        }
    });
```

### Response

The `addChannelsToChannelGroup()` does not return actionable data, be sure to check the status object on the outcome of the operation by checking the `status.isError()`.

```json
{
    "service" : "channel-registry",
    "status"  : 200,
    "error"   : false,
    "message" : "OK"
}
```

## List channels in a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function lists all channels in a channel group.

### Method(s)

Use the following method in the Android SDK:

```java
pubnub.listChannelsForChannelGroup()
    .channelGroup(String)
```

| Parameter | Description |
| --- | --- |
| `channelGroup` *Type: String | The channel group for which to list channels. |
| `async` *Type: PNCallback | `PNCallback` of type `PNChannelGroupsAllChannelsResult`. |

### Sample code

#### List channels

```java
pubnub.listChannelsForChannelGroup()
    .channelGroup("cg1")
    .async(new PNCallback<PNChannelGroupsAllChannelsResult>() {
        @Override
        public void onResponse(PNChannelGroupsAllChannelsResult result, PNStatus status) {

        }
    });
```

### Returns

The `listChannelsForChannelGroup()` operation returns a `PNChannelGroupsAllChannelsResult` which contains the following operations:

| Method | Description |
| --- | --- |
| `getChannels()`Type: List`<String>` | List of `channels` of a `channel group`. |

## Remove channels from a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function removes channels from a channel group.

### Method(s)

Use the following method in the Android SDK:

```java
pubnub.removeChannelsFromChannelGroup()
    .channelGroup(String)
    .channels(Array)
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: Array | The channels to remove from the channel group. |
| `channelGroup` *Type: String | The channel group from which to remove the channels. |
| `async`Type: PNCallback | `PNCallback` of type `PNChannelGroupsRemoveChannelResult`. |

### Sample code

#### Remove channels

```java
pubnub.removeChannelsFromChannelGroup()
    .channelGroup("family")
    .channels(Arrays.asList("son"))
    .async(new PNCallback<PNChannelGroupsRemoveChannelResult>() {
        @Override
        public void onResponse(PNChannelGroupsRemoveChannelResult result, PNStatus status) {

        }
    });
```

### Response

The `removeChannelsFromChannelGroup()` does not return actionable data, be sure to check the status object on the outcome of the operation by checking the `status.isError()`.

```json
{
    "status" : 200,
    "message" : "OK",
    "service" : "channel-registry",
    "error" : False
}
```

## Delete a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function deletes a channel group.

### Method(s)

Use the following method in the Android SDK:

```java
pubnub.deleteChannelGroup()
    .channelGroup(String)
```

| Parameter | Description |
| --- | --- |
| `channelGroup` *Type: String | The channel group to delete. |
| `async`Type: PNCallback | `PNCallback` of type `PNChannelGroupsDeleteGroupResult`. |

### Sample code

#### Delete channel group

```java
pubnub.deleteChannelGroup()
    .channelGroup("family")
    .async(new PNCallback<PNChannelGroupsDeleteGroupResult>() {
        @Override
        public void onResponse(PNChannelGroupsDeleteGroupResult result, PNStatus status) {

        }
    });
```

### Response

The `deleteChannelGroup()` does not return actionable data, be sure to check the status object on the outcome of the operation by checking the `status.isError()`.

```json
{
    "status" : 200,
    "message" : "OK",
    "service" : "channel-registry",
    "error" : False
}
```

## Terms in this document

* **Channel** - A pathway for sending and receiving messages between devices, created automatically when you first use it, that can handle any number of users and messages for different communication needs, like 1-1 text chats, group conversations, and other data streaming.
* **PubNub** - PubNub is a real-time messaging platform that provides APIs and SDKs for building scalable applications. It handles the complex infrastructure of real-time communication, including: Message delivery and persistence, Presence detection, Access control, Push notifications, File sharing, Serverless processing with Functions and Events & Actions, Analytics and monitoring with BizOps Workspace, AI-powered insights with Illuminate.
