/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Search open channels by name, URL, or custom type

Copy link

You can search for specific open channels by adding keywords to an OpenChannelListQuery instance. There are two types of keywords, which are name and URL.

The code sample below shows the query instance which returns a list of open channels that partially match the specified nameKeyword in their channel names.

val query = OpenChannel.createOpenChannelListQuery(
    OpenChannelListQueryParams().apply {
        nameKeyword = "Sendbird"
    }
)
query.next { channels, e ->
    if (e != null) {
        // Handle error.
    }

    // Through the channels parameter of the callback handler, which the Sendbird server has passed a result list to,
    // a list of open channels whose name partially matches the filter value is returned.
    // ...
}

The following shows the query instance which returns a list of open channels that partially match the specified urlKeyword in their channel URLs.

val query = OpenChannel.createOpenChannelListQuery(
    OpenChannelListQueryParams().apply {
        urlKeyword = "seminar"
    }
)
query.next { channels, e ->
    if (e != null) {
        // Handle error.
    }

    // Through the channels parameter of the callback handler,
    // which the Sendbird server has passed a result list to,
    // a list of open channels whose URL partially matches the filter value is returned.
    // ...
}

You can also search for open channels with a specific custom type by setting customType as in the following code.

val query = OpenChannel.createOpenChannelListQuery(
    OpenChannelListQueryParams().apply {
        customType = "movie"
    }
)
query.next { channels, e ->
    if (e != null) {
        // Handle error.
    }

    // Through the channels parameter of the callback handler,
    // which the Sendbird server has passed a result list to,
    // a list of open channels whose custom type matches the filter value is returned.
    // ...
}