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

# Quick Start

> Learn how to install QuickBlox SDK and send your first message.

QuickBlox SDK helps you implement a real-time chat, video chat, and push notifications to your app. You can fully concentrate on your mobile app development. QuickBlox Android SDK supports both **Java** and **Kotlin** programming languages.

## Start with sample apps

If you are just starting your app and developing it from scratch, we recommend to use our sample apps. We use GitHub repositories to make it easy to explore, copy, and modify our code samples. The guide on how to launch and configure the sample app is on GitHub.

### Chat samples

Choose the code sample below to jump-start the development.

<CardGroup>
  <Card title="Java Chat Sample App" icon="java">
    <a className="inline-link" href="https://github.com/QuickBlox/quickblox-android-sdk/tree/master/sample-chat-java">
      <Icon icon="github" /> View on GitHub
    </a>

    <br />

    <a className="inline-link" href="/sdks/android-chat">
      <Icon icon="book" />  Documentation
    </a>
  </Card>

  <Card
    title="Kotlin Chat Sample App"
    icon={<svg
  width="22px"
  height="23px"
  viewBox="0 0 22 23"
  xmlns="http://www.w3.org/2000/svg"
  xmlnsXlink="http://www.w3.org/1999/xlink"
>
  <defs>
    <linearGradient x1="0%" y1="0%" x2="50%" y2="50%" id="linearGradient-1">
      <stop stopColor="#3978fc" offset="0%" />
      <stop stopColor="#3978fc" offset="100%" />
    </linearGradient>
    <linearGradient x1="-21.6846517%" y1="107.628997%" x2="84.7001079%" y2="0%" id="linearGradient-2">
      <stop stopColor="#3978fc" offset="0%" />
      <stop stopColor="#3978fc" offset="100%" />
    </linearGradient>
    <linearGradient x1="0%" y1="72.8348211%" x2="100%" y2="-15.9724705%" id="linearGradient-3">
      <stop stopColor="#3978fc" offset="0%" />
      <stop stopColor="#3978fc" offset="100%" />
    </linearGradient>
  </defs>
  <g fill="none" fillRule="evenodd">
    <g transform="translate(-533.000000, -1249.000000)">
      <g transform="translate(400.000000, 1109.000000)">
        <g transform="translate(25.000000, 139.000000)">
          <g transform="translate(108.000000, 1.500000)">
            <polygon
              fill="url(#linearGradient-1)"
              transform="translate(10.875000, 10.875000) scale(1, -1) translate(-10.875000, -10.875000)"
              points="0 0 21.75 0 0 21.75"
            />
            <polygon fill="url(#linearGradient-2)" points="0 0 21.75 0 0 21.75" />
            <polygon fill="url(#linearGradient-3)" points="0 0 12 0 0 12" />
          </g>
        </g>
      </g>
    </g>
  </g>
</svg>}
  >
    <a className="inline-link" href="https://github.com/QuickBlox/quickblox-android-sdk/tree/master/sample-chat-kotlin">
      <Icon icon="github" /> View on GitHub
    </a>

    <br />

    <a className="inline-link" href="/sdks/android-chat">
      <Icon icon="book" />  Documentation
    </a>
  </Card>
</CardGroup>

### Video chat sample

Choose the code sample below to jump-start the development.

<CardGroup>
  <Card title="Java Video Calling Sample App" icon="java">
    <a className="inline-link" href="https://github.com/QuickBlox/quickblox-android-sdk/tree/master/sample-videochat-java">
      <Icon icon="github" /> View on GitHub
    </a>

    <br />

    <a className="inline-link" href="/sdks/android-video-calling">
      <Icon icon="book" />  Documentation
    </a>
  </Card>

  <Card
    title="Kotlin Video Calling Sample App"
    icon={<svg
  width="22px"
  height="23px"
  viewBox="0 0 22 23"
  xmlns="http://www.w3.org/2000/svg"
  xmlnsXlink="http://www.w3.org/1999/xlink"
>
  <defs>
    <linearGradient x1="0%" y1="0%" x2="50%" y2="50%" id="linearGradient-1">
      <stop stopColor="#3978fc" offset="0%" />
      <stop stopColor="#3978fc" offset="100%" />
    </linearGradient>
    <linearGradient x1="-21.6846517%" y1="107.628997%" x2="84.7001079%" y2="0%" id="linearGradient-2">
      <stop stopColor="#3978fc" offset="0%" />
      <stop stopColor="#3978fc" offset="100%" />
    </linearGradient>
    <linearGradient x1="0%" y1="72.8348211%" x2="100%" y2="-15.9724705%" id="linearGradient-3">
      <stop stopColor="#3978fc" offset="0%" />
      <stop stopColor="#3978fc" offset="100%" />
    </linearGradient>
  </defs>
  <g fill="none" fillRule="evenodd">
    <g transform="translate(-533.000000, -1249.000000)">
      <g transform="translate(400.000000, 1109.000000)">
        <g transform="translate(25.000000, 139.000000)">
          <g transform="translate(108.000000, 1.500000)">
            <polygon
              fill="url(#linearGradient-1)"
              transform="translate(10.875000, 10.875000) scale(1, -1) translate(-10.875000, -10.875000)"
              points="0 0 21.75 0 0 21.75"
            />
            <polygon fill="url(#linearGradient-2)" points="0 0 21.75 0 0 21.75" />
            <polygon fill="url(#linearGradient-3)" points="0 0 12 0 0 12" />
          </g>
        </g>
      </g>
    </g>
  </g>
</svg>}
  >
    <a className="inline-link" href="https://github.com/QuickBlox/quickblox-android-sdk/tree/master/sample-videochat-kotlin">
      <Icon icon="github" /> View on GitHub
    </a>

    <br />

    <a className="inline-link" href="/sdks/android-video-calling">
      <Icon icon="book" />  Documentation
    </a>
  </Card>
</CardGroup>

### More samples

For more samples, head to our [Code Samples](/code-samples/code-samples) page. These sample apps are available on GitHub so feel free to browse them there. Just clone the repository and modify the source code for your own projects.

## Get application credentials

QuickBlox application includes everything that brings messaging right into your application - chat, video calling, users, push notifications, etc. To create a QuickBlox application, follow the steps below:

1. Register a new account following [this link](https://admin.quickblox.com/signup). Type in your email and password to sign in. You can also sign in with your Google or GitHub accounts.
2. Create the app clicking **New app** button.
3. Configure the app. Type in the information about your organization into corresponding fields and click **Add** button.
4. Go to **Dashboard => *YOUR\_APP* => Overview**  section and copy your **Application ID**, **Authorization Key**, **Authorization Secret**, and **Account Key** .

## Requirements

The minimum requirements for QuickBlox Android SDK are:

* Android 5.0 (API 21)
* Android Studio
* Gradle 4.6
* Gradle plugin 2.5.1

## Install QuickBlox SDK into your app

To connect QuickBlox SDK to your app, import QuickBlox SDK dependencies via **build.gradle** file.

Include reference to SDK repository in your **project-level build.gradle** file at the **root** directory. Specify the URL of QuickBlox repository where the files are stored. Following this URL gradle finds SDK artifacts.

```Groovy Groovy theme={null}
allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/"
        }
    }
}
```

When the artifacts are found in QuickBlox repository, they get imported to particular SDK modules in **build.gradle** project file. Add the following code lines to **app-level build.gradle** file.

```Groovy Groovy theme={null}
dependencies {
    implementation "com.quickblox:quickblox-android-sdk-messages:4.3.0"
    implementation "com.quickblox:quickblox-android-sdk-chat:4.3.0"
    implementation "com.quickblox:quickblox-android-sdk-content:4.3.0"
    implementation "com.quickblox:quickblox-android-sdk-videochat-webrtc:4.3.0"
    implementation "com.quickblox:quickblox-android-sdk-conference:4.3.0"
    implementation "com.quickblox:quickblox-android-sdk-customobjects:4.3.0"
}
```

## Send your first message

### Initialize QuickBlox SDK

Initialize the SDK with your application credentials. Pass the `APPLICATION_ID`, `AUTH_KEY`, `AUTH_SECRET`, and `ACCOUNT_KEY` to the `init()` method.

<Tabs>
  <Tab title="Java">
    ```Java theme={null}
    static final String APPLICATION_ID = "67895";
    static final String AUTH_KEY = "lkjdueksu7392kj";
    static final String AUTH_SECRET = "BTFsj7Rtt27DAmT";
    static final String ACCOUNT_KEY = "9yvTe17TmjNPqDoYtfqp";
    //
    QBSettings.getInstance().init(getApplicationContext(), APPLICATION_ID, AUTH_KEY, AUTH_SECRET);
    QBSettings.getInstance().setAccountKey(ACCOUNT_KEY);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```Kotlin theme={null}
    private const val APPLICATION_ID = "67895"
    private const val AUTH_KEY = "lkjdueksu7392kj"
    private const val AUTH_SECRET = "BTFsj7Rtt27DAmT"
    private const val ACCOUNT_KEY = "9yvTe17TmjNPqDoYtfqp"
    //
    QBSettings.getInstance().init(applicationContext, APPLICATION_ID, AUTH_KEY, AUTH_SECRET)
    QBSettings.getInstance().accountKey = ACCOUNT_KEY
    ```
  </Tab>
</Tabs>

<Warning>
  You must initialize SDK before calling any methods through the SDK, except for the `init()` method. If you attempt to call a method without connecting, the error is returned.
</Warning>

<Tip>
  Security

  It's not recommended to keep your **authKey** and **authSecret** inside an application in production mode, instead of this, the best approach will be to store them on your backend and initialize QuickBlox SDK with applicationId and acountKey only. More details you can find in [Initialize QuickBlox SDK without Authorization Key and Secret](/sdks/android-setup#initialize-quickblox-sdk-without-authorization-key-and-secret) section.
</Tip>

### Authorize user

Now, it is time to log in with the user. To get it done, set the login and password of the `user`, call the `signIn()` method, and pass the `user` to it using the code snippet below.

<Tabs>
  <Tab title="Java">
    ```Java theme={null}
    final QBUser user = new QBUser();
    user.setLogin("johnsmith");
    user.setPassword("johnPassword");

    QBUsers.signIn(user).performAsync(new QBEntityCallback<QBUser>() {
        @Override
        public void onSuccess(QBUser user, Bundle bundle) {

        }

        @Override
        public void onError(QBResponseException exception) {

        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```Kotlin Kotlin theme={null}
    val user = QBUser()
    user.login = "johnsmith"
    user.password = "johnPassword"

    QBUsers.signIn(user).performAsync(object : QBEntityCallback<QBUser> {
        override fun onSuccess(user: QBUser?, bundle: Bundle?) {

        }

        override fun onError(exception: QBResponseException?) {

        }
    })
    ```
  </Tab>
</Tabs>

### Connect to chat

Having authorized a user, you can proceed with connecting to the chat server to start using Chat module functionality. Call the `login()` method to connect to the chat server.

<Tabs>
  <Tab title="Java">
    ```Java Java theme={null}
    final QBUser user = new QBUser();
    user.setId(12345);
    user.setPassword("johnPassword");

    QBChatService.getInstance().login(user, new QBEntityCallback() {
        @Override
        public void onSuccess(Void aVoid, Bundle bundle) {

        }

        @Override
        public void onError(QBResponseException exception) {

        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```Kotlin Kotlin theme={null}
    val user = QBUser()
    user.id = 12315
    user.password = "johnPassword"

    QBChatService.getInstance().login(user, object : QBEntityCallback<Void> {
        override fun onSuccess(aVoid: Void?, bundle: Bundle?) {

        }

        override fun onError(exception: QBResponseException?) {

        }
    })
    ```
  </Tab>
</Tabs>

### Create dialog

QuickBlox provides three types of dialogs: **1-1 dialog**, **group dialog**, and **public dialog**. Learn more about dialogs [here](/sdks/android-chat-dialogs#create-dialog).

Let’s create a simple **1-1 dialog**. Set the type and occupants IDs of the `dialog` using the the `setType()` and `setOccupantsIds()` methods. Then, call the `createChatDialog()` method and pass the `dialog` to it.

<Tabs>
  <Tab title="Java">
    ```Java Java theme={null}
    ArrayList<Integer> occupantIdsList = new ArrayList<Integer>();
    int occupantId = 123;
    occupantIdsList.add(occupantId);

    QBChatDialog dialog = new QBChatDialog();
    dialog.setType(QBDialogType.PRIVATE);
    dialog.setOccupantsIds(occupantIdsList);

    // or just use DialogUtils
    //QBChatDialog dialog = DialogUtils.buildPrivateDialog(recipientId);

    QBRestChatService.createChatDialog(dialog).performAsync(new QBEntityCallback<QBChatDialog>() {
        @Override
        public void onSuccess(QBChatDialog result, Bundle bundle) {

        }

        @Override
        public void onError(QBResponseException exception) {

        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```Kotlin Kotlin theme={null}
    val occupantIdsList = ArrayList<Int>()
    val occupantId = 123
    occupantIdsList.add(occupantId)

    val dialog = QBChatDialog()
    dialog.type = QBDialogType.PRIVATE
    dialog.setOccupantsIds(occupantIdsList)

    // or just use DialogUtils
    //QBChatDialog dialog = DialogUtils.buildPrivateDialog(recipientId);

    QBRestChatService.createChatDialog(dialog).performAsync(object : QBEntityCallback<QBChatDialog> {
        override fun onSuccess(result: QBChatDialog?, bundle: Bundle?) {

        }

        override fun onError(exception: QBResponseException?) {

        }
    })
    ```
  </Tab>
</Tabs>

### Subscribe to receive messages

Through `QBDialogMessageListener` you can monitor whether an incoming message or error is received from QuickBlox server. Use `QBIncomingMessagesManager` to listen to all incoming messages and related errors.

<Tabs>
  <Tab title="Java">
    ```Java Java theme={null}
    QBChatService chatService = QBChatService.getInstance();
    QBIncomingMessagesManager incomingMessagesManager = chatService.getIncomingMessagesManager();

    incomingMessagesManager.addDialogMessageListener(new QBChatDialogMessageListener() {
        @Override
        public void processMessage(String dialogId, QBChatMessage chatMessage, Integer senderId) {

        }

        @Override
        public void processError(String dialogId, QBChatException exception, QBChatMessage chatMessage, Integer senderId) {

        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```Kotlin Kotlin theme={null}
    val chatService = QBChatService.getInstance()
    val incomingMessagesManager = chatService.incomingMessagesManager

    incomingMessagesManager.addDialogMessageListener(object : QBChatDialogMessageListener {
        override fun processMessage(dialogID: String?, qbChatMessage: QBChatMessage?, senderID: Int?) {

        }

        override fun processError(dialogID: String?, e: QBChatException?, qbChatMessage: QBChatMessage?, senderID: Int?) {

        }
    })
    ```
  </Tab>
</Tabs>

### Send message

To send a message, create `QBChatMessage` instance and set a text message using the `setBody()` method. Then, call the `sendMessage()` method.

<Tabs>
  <Tab title="Java">
    ```Java Java theme={null}
    QBChatMessage chatMessage = new QBChatMessage();
    chatMessage.setBody("Hello QuickBlox!");
    chatMessage.setSaveToHistory(true);

    dialog.sendMessage(chatMessage, new QBEntityCallback<Void>() {
        @Override
        public void onSuccess(Void aVoid, Bundle bundle) {

        }

        @Override
        public void onError(QBResponseException exception) {

        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```Kotlin Kotlin theme={null}
    val chatMessage = QBChatMessage()
    chatMessage.body = "Hello QuickBlox!"
    chatMessage.setSaveToHistory(true)

    dialog.sendMessage(chatMessage, object : QBEntityCallback<Void> {
        override fun onSuccess(aVoid: Void?, bundle: Bundle?) {

        }

        override fun onError(exception: QBResponseException?) {

        }
    })
    ```
  </Tab>
</Tabs>

<Note>
  Set the `saveToHistory` parameter if you want this message to be saved in the chat history.
</Note>
