> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Overview of Overview in CometChat.

<Note>
  🚀 **CometChat Android UI Kit v6 is now available!** It features a completely revamped component architecture and improved theming. [Try the v6 →](/ui-kit/android/v6/overview)
</Note>

<Note>
  Reference for Kotlin UI Kit.

  Check out our Kotlin UI Kit [here](/ui-kit/kotlin/customize-ui-kit).
</Note>

The CometChat Android Java UI Kit lets developers integrate text chat & voice/video calling features into Android apps seamlessly.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/Xbd1mrZiWe1Pd3HE/images/90ff7169-1623200048-cd40aae8348c6370bf5b3526e6dbda7c.png?fit=max&auto=format&n=Xbd1mrZiWe1Pd3HE&q=85&s=877e45406135e801d4dcceb54286722b" width="652" height="268" data-path="images/90ff7169-1623200048-cd40aae8348c6370bf5b3526e6dbda7c.png" />
</Frame>

<Tip>
  👍 Improvements in v3.0

  * Faster connection & response times
  * Higher rate limits
  * Supports up to 100K users in a group
  * Unlimited groups
  * Support for Transient Messages
  * Real-time user & group members count
</Tip>

The Android Java UI Kit’s fully customizable UI components simplify the process of integrating text chat and voice/video calling features to your website or mobile application in a few minutes.

<CardGroup>
  <Card title="I want to checkout Android Java UI Kit.">
    Follow the steps mentioned in the `README.md` file.

    Kindly, click on below button to download our Android Java Chat UI Kit.

    [Java Chat UI Kit](https://github.com/cometchat-pro/android-java-chat-ui-kit/archive/v3.zip)

    [View on Github](https://github.com/cometchat/cometchat-chat-uikit-android-java/tree/v3)

    **I want to integrate UI Kit with my App**

    * [UI Components](/ui-kit/android/v3/android-java-ui-components)
    * [Customize UI Kit](/ui-kit/android/v3/android-customize-ui-kit)
  </Card>

  <Card title="I want to explore sample apps.">
    Import the app into Android Studio and follow the steps mentioned in the `README.md` file.

    Kindly, click on below button to download our Java Sample App.

    [Java Sample App](https://github.com/cometchat-pro-samples/android-java-chat-app/archive/v3.zip)

    [View on Github](https://github.com/cometchat/cometchat-chat-sample-app-android-java/tree/v3)
  </Card>
</CardGroup>

### Prerequisites ⭐

Before you begin, ensure you have met the following requirements:

✅ You have `Android Studio` installed in your machine.

✅ You have a `Android Device or Emulator` with Android Version 6.0 or above.

✅ You have read [CometChat Key Concepts](/ui-kit/android/v3/key-concepts).

## Installing Android Java Chat UI Kit

### Setup 🔧

To setup Android Java Chat UI Kit, you need to first register on CometChat Dashboard. [Click here to sign up](https://app.cometchat.com/login).

#### Get your Application Keys 🔑

1. Create a new app: Click **Add App** option available → Enter App Name & other information → Create App
2. You will find `APP_ID`, `AUTH_KEY` and `REGION` key at the top in **QuickStart** section or else go to "API & Auth Keys" section and copy the `APP_ID`, `API_KEY` and `REGION` key from the "Auth Only API Key" tab.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/QxoaCZzLrVi321Ps/images/3fb03aef-1631572058-06b4f0f4b8570ca81cc5a0de591c1892.jpg?fit=max&auto=format&n=QxoaCZzLrVi321Ps&q=85&s=7df23282ad672636ee9e3819b4dcd37f" width="973" height="375" data-path="images/3fb03aef-1631572058-06b4f0f4b8570ca81cc5a0de591c1892.jpg" />
</Frame>

#### Add the CometChat Dependency

**Step 1 -** Add the repository URL to the **project level**`build.gradle` file in the repositories block under the `allprojects` section.

<Tabs>
  <Tab title="build.gradle">
    ```gradle theme={null}
    allprojects {
      repositories {
        maven {
          url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/"
        }
      }
    }
    ```
  </Tab>
</Tabs>

**Step 2-** Open the **app level**`build.gradle` file and follow below

1. Add the below line in the dependencies section.

<Tabs>
  <Tab title="build.gradle">
    ```gradle theme={null}
    dependencies {
      implementation 'com.cometchat:pro-android-chat-sdk:3.0.1'

    	/*v2.4+ onwards, Voice & Video Calling functionality has been
      moved to a separate library. In case you plan to use the calling feature,
      please add the Calling dependency*/
    	implementation 'com.cometchat:pro-android-calls-sdk:2.1.1'
    }
    ```
  </Tab>
</Tabs>

2. Add the below lines android section

<Tabs>
  <Tab title="build.gradle">
    ```gradle theme={null}
    android {
      compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
      }
    }
    ```
  </Tab>
</Tabs>

You can refer to the below link for instructions on how to do so:

**[📝 Add CometChat Dependency](/sdk/android/setup)** `Documentation`

***

### Configure CometChat SDK

#### Initialize CometChat 🌟

The `init()` method initializes the settings required for CometChat. Please make sure to call this method before calling any other methods from CometChat SDK.

<Tabs>
  <Tab title="java">
    ```java theme={null}
    String appID = "APP_ID"; // Replace with your App ID
    String region = "REGION"; // Replace with your App Region ("eu" or "us")
    String authKey = "AUTH_KEY"; //Replace with your Auth Key.

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

    CometChat.init(this, appID,appSettings, new CometChat.CallbackListener<String>() {
      @Override
      public void onSuccess(String successMessage) {
        UIKitSettings.setAuthKey(authKey);
        CometChat.setSource("ui-kit","android","java");
        Log.d(TAG, "Initialization completed successfully");
      }
      @Override
      public void onError(CometChatException e) {
        Log.d(TAG, "Initialization failed with exception: " + e.getMessage());
      }
    });
    ```
  </Tab>
</Tabs>

`Tip` UIKitSettings.setAuthKey(String authKey) is used to pass the Auth Key to uiKit library.

<Note>
  Make sure to replace `region` and `appID` with your credentials in the above code snippet.
</Note>

#### Login User 👤

Once you have created the user successfully, you will need to log the user into CometChat using the login() method.

<Tabs>
  <Tab title="java">
    ```java theme={null}
    String UID = "user1"; // Replace with the UID of the user to login
            String authKey = "AUTH_KEY"; // Replace with your App Auth Key

            if (CometChat.getLoggedInUser() == null) {
            CometChat.login(UID, authKey, new CometChat.CallbackListener<User>() {

    @Override
    public void onSuccess(User user) {
            Log.d(TAG, "Login Successful : " + user.toString());
            }

    @Override
    public void onError(CometChatException e) {
            Log.d(TAG, "Login failed with exception: " + e.getMessage());
            }
            });
            } else {
            // User already logged in
            }
    ```
  </Tab>
</Tabs>

<Note>
  * The `login()` method needs to be called only once.
  * Replace `AUTH_KEY` with your App Auth Key in the above code snippet.
</Note>

***

📝 Please refer to our **[SDK Documentation](/sdk/android/overview)** for more information on how to configure the CometChat Pro SDK and implement various features using the same.

### Add Android Java UI Kit Library

To integrate the Android Java UI Kit, please follow the steps below:

* Clone the UI Kit Library from the [android-chat-ui-kit repository](https://github.com/cometchat-pro/android-java-chat-ui-kit) or

[Java Download UI Kit Library](https://github.com/cometchat-pro/android-java-chat-ui-kit/archive/v3.zip)

* Import `uikit` Module from Module Settings.(Click **[here](/ui-kit/android/v3/how-to-add-uikit-module)** to know how to import `uikit` as Module)
* If the Library is added sucessfully, it will look like mentioned in the below image.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/8YlylzCf9CehSaWO/images/cba6bc38-1623200050-f9161efecbbd4d0210e9430df685bd0b.jpg?fit=max&auto=format&n=8YlylzCf9CehSaWO&q=85&s=3d4c20254f5971511a097869ca9e0538" width="415" height="429" data-path="images/cba6bc38-1623200050-f9161efecbbd4d0210e9430df685bd0b.jpg" />
</Frame>

### Configure Android Java UI Kit Library

To use UI Kit you have to add Material Design support in your app as the UI Kit uses Material Design Components.

* Add Material Design Dependency in build.gradle

<Tabs>
  <Tab title="build.gradle">
    ```gradle theme={null}
    dependencies {
      implementation 'com.google.android.material:material:<version>'
    }
    ```
  </Tab>
</Tabs>

* Make sure that your app's theme should extend `Theme.MaterialComponents`. Follow the guide on [Getting started Material Components](https://material.io/develop/android/docs/getting-started/)

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

* `Theme.MaterialComponents.NoActionBar`
* Theme.MaterialComponents.Light.NoActionBar
* Theme.MaterialComponents.DayNight.NoActionBar

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

<Tabs>
  <Tab title="xml">
    ```xml theme={null}
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">

    	    <!-- Customize your theme here. -->
    </style>
    ```
  </Tab>
</Tabs>

<Info>
  Enable DataBinding

  As the UI Kit uses DataBinding you must enable DataBinding
</Info>

To configure your app to use data binding, add the dataBinding element to your `build.gradle` file in the app module, as shown in the following example:

<Tabs>
  <Tab title="build.gradle">
    ```gradle theme={null}
    android {
        dataBinding {
            enabled = true
        }
    }
    ```
  </Tab>
</Tabs>

Open the `gradle.properties` and check if the below stated line is present or not, if not then simply add it.

<Tabs>
  <Tab title="gradle.properties">
    ```
    android.enableJetifier=true
    ```
  </Tab>
</Tabs>

<Warning>
  > We are using File Provider for storage & file access. So you need to add your application package name in manifestPlaceholders
</Warning>

<Tabs>
  <Tab title="build.gradle">
    ```gradle theme={null}
    android {
    		defaultConfig {
    			...

    			manifestPlaceholders = [file_provider: "YOUR_PACKAGE_NAME"]
    			//add your application package.
    		}
    	}
    ```
  </Tab>
</Tabs>

### Launch CometChat UI

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/v4EbHQCGZ54oJcmr/images/5934aeb2-1624892364-9b55a580ac39dd34477bb63def96d45b.png?fit=max&auto=format&n=v4EbHQCGZ54oJcmr&q=85&s=73c977c16da15f5a53ae1bac09c7af81" width="4260" height="2800" data-path="images/5934aeb2-1624892364-9b55a580ac39dd34477bb63def96d45b.png" />
</Frame>

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

To use CometChatUI user has to launch `CometChatUI` class. Add the following code snippet to launch `CometChatUI`.

<Tabs>
  <Tab title="java">
    ```java theme={null}
    startActivity(new Intent(YourActivity.this,CometChatUI.class))
    ```
  </Tab>
</Tabs>

***

## Checkout our Android Java sample app

Visit our [Java sample app](https://github.com/cometchat-pro/android-java-chat-app/tree/v3)repository to run the Android Java sample app.
