Applozic Android SDK Tutorial 3 - Chat Conversations
Tags: android, tutorial, java, applozic
Published: 2021-06-30 09:32:10

##Introduction

<!-- wp:paragraph -->
<p>This tutorial is Part 3 of a multi-part series covering Applozic Android SDK integration into an Android app.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Our goal is to learn the following steps in this tutorial:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Launch Conversation list screen</li><li>Create individual chat thread</li><li>Create group chat thread</li><li>Create context based chat thread</li><li>Delete chat threads</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>You can download the sample Android chat app from <a href="https://github.com/AppLozic/Applozic-Android-SDK" target="_blank" rel="noreferrer noopener">Applozic GitHub</a>. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Conversation screen</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>To give you an idea of what the conversation screen would look like in the final app, take a look at the screenshot below.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2162,"width":461,"height":1024,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large is-resized"><img src="https://www.applozic.com/blog/wp-content/uploads/2021/06/tutorial-3-chat-screen-461x1024.jpg" alt="conversation screen" class="wp-image-2162" width="461" height="1024"/><figcaption>Android Conversation screen</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>To get started with such a conversation screen, add the following code:</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>Intent intent = new Intent(this, ConversationActivity.class);            
startActivity(intent);</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>You can set this to activate&nbsp;as soon as the user opens the conversation screen. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Individual Chat</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>From the main conversation screen, the user can choose to launch either an individual conversation thread or a group chat thread. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>An individual chat screen will look like this:</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2163,"width":461,"height":1024,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large is-resized"><img src="https://www.applozic.com/blog/wp-content/uploads/2021/06/tutorial-3-single-chat-screen-461x1024.jpg" alt="Individual chat screen" class="wp-image-2163" width="461" height="1024"/><figcaption>Individual chat screen</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>For starting individual conversation thread, set "userId" in intent:</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>Intent intent = new Intent(this, ConversationActivity.class);            
intent.putExtra(ConversationUIService.USER_ID, "receiveruserid123");   
intent.putExtra(ConversationUIService.DISPLAY_NAME, "Receiver display name"); 
//to display the title.
intent.putExtra(ConversationUIService.TAKE_ORDER,true); 
//Skip chat list on back press 
startActivity(intent);</code></pre>
<!-- /wp:code -->

<!-- wp:heading -->
<h2>Group Chat</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A group conversation contains multiple users that can send and receive messages. Internally, a group conversation is referred to as a&nbsp;<strong>channel</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Applozic supports multiple group types that serve different purposes. </p>
<!-- /wp:paragraph -->

<!-- wp:table -->
<table><thead><tr><th>Value</th><th>Name</th><th>Description</th></tr></thead><tbody><tr><td>1</td><td>Private Group</td><td>Private groups are not accessible to contacts other than the ones present in the group. Only group admin can add/remove members in the group. You can create private groups to facilitate close, WhatsApp style interactions. For example, doctor-patient chats.</td></tr><tr><td>2</td><td>Public Group</td><td>Users will be able to search and join Public groups. Any group member can add/remove members in this group. For example, Public groups can be used to create area-wise communities in a social app where users can search their area's community and join.</td></tr><tr><td>5</td><td>Broadcast Group</td><td>A message can be sent to several contacts at once. Messages sent in the broadcast group are received by the members of the group as one-to-one chat thread. Only the sender can see the broadcast group. The broadcast group works on a similar behavior as that of WhatsApp broadcasts.</td></tr><tr><td>6</td><td>Open Group</td><td>Used for free-flowing chats such as live streaming chats, live event chats etc. You need not add any members to this group. All users present on the chat screen will receive messages via MQTT (<a rel="noreferrer noopener" href="https://www.applozic.com/blog/real-time-updates-in-your-chat-app-using-pub-sub/" target="_blank">publish/subscribe pattern</a>). Push notifications are not supported in Open groups.</td></tr><tr><td>7</td><td>GroupOfTwo</td><td>Used for the purpose where dealers are selling products and any particular user wants to chat about multiple products with the same dealer. At that time, it is required to show two different chat threads in the conversation history as the context (product) of the chats is different.</td></tr><tr><td>9</td><td>Contacts Group</td><td>Used for creating Friends/Favorites contact List. These lists can be maintained on the application level and any member of the group can access it. For example, an event management company can use the lists to maintain attendees of an event at one place.</td></tr><tr><td>10</td><td>Support Group</td><td>Best suited for people who want to use Applozic's sister product,&nbsp;<a href="https://www.kommunicate.io/">Kommunicate</a>. These groups are specifically built for the purpose of customer support chat and may contain multiple team members and chatbots talking to a user.</td></tr></tbody></table><figcaption>Table showcasing different group types</figcaption>
<!-- /wp:table -->

##Continue this Tutorial on Applozic Blog!
We have the detailed tutorial with code snippets available on [our blog](https://www.applozic.com/blog/applozic-android-sdk-tutorial-3-chat-conversations/) for you to continue with your integration!

[Click here](https://www.applozic.com/blog/applozic-android-sdk-tutorial-3-chat-conversations/) to learn how to:
* Create a group chat thread
* Create a context based chat thread
* Delete chat threads