CometChat Pro Documentation

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

Quick Start

Learn how to add CometChat to your Android app in minutes.

This guide demonstrates how to add chat to an Android application. Before you begin, we strongly recommend you read the Key Concepts guide.

I want to explore a sample app (includes UI Kit)

Import the app into Android Studio and follow the steps mentioned in the file.

Download UI Kit sample app

View on Github

Or check our Other sample app

Get your Application Keys

Signup for CometChat and then:

  1. Create a new app
  2. Head over to the API Keys section and note the API Key and App ID (for Auth Only key)

Minimum Requirement

Android API Level 21
Androidx Compatibility

Add the CometChat Dependency

First, add the repository URL to the project level build.gradle file in the repositories block under the allprojects section.

allprojects {
  repositories {
    maven {
      url ""

Then, add CometChat to the app level build.gradle file in the dependencies section.

dependencies {
  implementation 'com.cometchat:pro-android-chat-sdk:2.0.2'

Finally, add the below lines android section of the app level gradle file

android {
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8

Initialize CometChat

The init() method initializes the settings required for CometChat. We suggest calling the init() method on app startup, preferably in the onCreate() method of the Application class.

private String appID = "APP_ID";
private String region = "REGION";

AppSettings appSettings=new AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build();

CometChat.init(this, appID,appSettings, new CometChat.CallbackListener<String>() {
  public void onSuccess(String successMessage) {
    Log.d(TAG, "Initialization completed successfully");
  public void onError(CometChatException e) {
    Log.d(TAG, "Initialization failed with exception: " + e.getMessage());
val appID:String="APP_ID"
val region:String="REGION"

AppSettings appSetting = AppSettings.AppSettingsBuilder().setRegion(region).subscribePresenceForAllUsers().build();   

CometChat.init(this,appID,appSetting, object : CometChat.CallbackListener<String>() {
 override fun onSuccess(p0: String?) {
    Log.d(TAG, "Initialization completed successfully")

  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Initialization failed with exception: " + p0?.message)

Make sure you replace the APP_ID with your CometChat App ID and REGION with your app region in the above code.

Log in your User

Once initialization is successful, you will need to log the user into CometChat using the login() method.

We recommend you call the CometChat login() method once your user logs into your app. The login() method needs to be called only once.

private String UID = "SUPERHERO1";
private String apiKey = "API_KEY";

if (CometChat.getLoggedInUser()==null){
    CometChat.login(UID, apiKey, new CometChat.CallbackListener<User>() 
       public void onSuccess(User user) {
          Log.d(TAG, "Login Successful : " + user.toString());
       public void onError(CometChatException e) {
           Log.d(TAG, "Login failed with exception: " + e.getMessage());
  }else {
      // user already logged-in perform your action 
 val UID:String="SUPERHERO1"
 val apiKey:String="API_KEY"

CometChat.login(UID,apiKey, object : CometChat.CallbackListener<User>() {
     override fun onSuccess(p0: User?) {
         Log.d(TAG, "Login Successful : " + p0?.toString())        

     override fun onError(p0: CometChatException?) {
         Log.d(TAG, "Login failed with exception: " +  p0?.message)        


Make sure you replace the API_KEY with your CometChat API Key in the above code.

Sample Users

We have setup 5 users for testing having UIDs: SUPERHERO1, SUPERHERO2, SUPERHERO3, SUPERHERO4 and SUPERHERO5.

The login() method returns the User object containing all the information of the logged-in user.

Add UI Kit Library

Integrate UI Kit inside your app. Kindly follow the steps below:

  1. Simply clone the UI Kit Library from the android-chat-ui-kit repository.

  2. Import uikit Module from Module Settings.

  3. If the Library is added successfully, it will look like mentioned in the image below.

Launch UI Unified

UI Unified is a way to launch a fully working chat application using the UI Kit. UI Unified all UI Screens and UI Components working together to give the full experience of a chat application with minimal coding effort.

You can launch UI Unified after a successful login using CometChat.To use Unified UI you have to launch CometChatUnified Activity. Make sure to add the following code snippet in onSuccess of CometChat login.

startActivity(new Intent(YourActivity.this,CometChatUnified.class));

You can also use individual UI Screens or UI Components present in UI Kit.


As UI Kit is using material components your app's theme should extend Theme.MaterialComponents. Follow the guide on Getting started Material Components

The following is the list of Material Components themes you can use to get the latest component styles and theme-level attributes.


Update your app theme to inherit from one of these themes, e.g.:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">

    <!-- Customize your theme here. -->


Updated 6 days ago

Quick Start

Learn how to add CometChat to your Android app in minutes.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.