Nov 19, 2019 Meet Messages, Google's official app for texting (SMS, MMS) and chat (RCS). Message anyone from anywhere with the reliability of texting and the richness of chat. Stay in touch with friends and family, send group texts, and share your favorite pictures, GIFs, emoji, stickers, videos and audio messages. Clean, intuitive, and comfortable design Instant. Mar 28, 2017 Download Chat for Pokemon GO - GoChat apk 5.5 for Android. Get notifications when near monsters & pokestops. Chat with Pokemon Go trainers. Using APKPure App to upgrade Chat for Pokemon GO - GoChat, fast. But we like them a lot and hope our chat app makes their game play even better!
In this tutorial, we're going to be building a realtime group chat for Android using the Scaledrone Java API Client. It will work very similarly to apps such as WhatsApp, Facebook Messager and LINE.
You can find the full source code on GitHub.
This tutorial will teach you:
- How to build a fully functional group chat.
- Designing the UI elements such as chat bubbles and text inputs.
- How to use Scaledrone as the realtime backend of your app.
The project might seem daunting at first, but the messaging code outside of the layout files is pretty short.
Setting up the project
Start by creating a new Android project. We are using Android Studio, but this tutorial will work with any IDE of choice.
Import the Scaledrone module
To add the Scaledrone dependency to your app, you need to add it to your
build.gradle
file.For Android to allow us to connect to the internet, we need to add the internet permission to the
manifests/AndroidManifest.xml
file:Defining the UI layout
To start with the UI layout let's build the empty state. It consists of:
An empty
An
And finally, an
ListView
into where the messages will goAn
EditText
where the user can type their messageAnd finally, an
ImageButton
as a button to send the messageCartoon films free download for mobile. The base layout is defined in
/res/layout/activity_main.xml
:String constants are defined in
/res/layout/activity_main.xml
:The icon for the send button is defined in
/res/drawable/ic_send_black_24dp.xml
:Next up, chat bubbles!
Our chat app is going to have two type of chat bubbles: a bubble for messages sent by us and bubbles for messages sent by others.
Chat bubble sent by us
The messages sent by us will look dark and be aligned to the right. We're using a drawable to get the border radius effect.
/res/drawable/my_message.xml
:The message itself is just a simple
TextView
aligned to the right./res/layout/my_message.xml
:Chat bubble sent by others
The chat bubble sent by others within the group chat will be light and aligned to the left. In addition to the bubble itself, we will show an avatar (as a simple full-color circle) and the name of the user.
For the avatar let's define a circle shape under
/res/drawable/circle.xml
:And for the bubble let's create a shape with curved corners and the sharp corner on the left. This goes in
/res/drawable/their_message.xml
:Putting it together their message bubble layout under
/res/layout/their_message.xml
will look like this:Hooking up the realtime messaging logic
We're finally done with the layout and can get to the interesting part!
Let's find the
EditText
view from our layout and extend Scaledrone's RoomListener
so we could receive messages. Most of the methods will have minimal code in them, and we'll fill them up as the tutorial goes along.Connecting to Scaledrone
If you don't have a Scaledrone account yet, open up Scaledrone.com and create a new free account. To successfully connect to Scaledrone you need to get your own channel ID from the Scaledrone's dashboard. To do that go to the dashboard and click the big green +Create Channel button to get started. You can choose Never require authentication for now. Copy the channel ID from the just created channel and replace
CHANNEL_ID_FROM_YOUR_SCALEDRONE_DASHBOARD
with it.Connecting to Scaledrone can happen within the
onCreate()
method, right after we have set up the UI. Scaledrone gives us the ability to attach arbitrary data to a user (users are called members in Scaledrone lingo), we're going to be adding a random name and color.You might have noticed that we named our name Scaledrone room observable-room. You can name the room anything you want, a single user can actually connect to an infinite amount of rooms to provider for all sorts of application scenarios. https://powerfulever.weebly.com/download-hollywood-movies-for-mobile-in-hd-quality.html. However in order for messages to contain the info of the sender the room name needs to be prefixed with observable-. Read more.
To create the MemberData let's implement the
getRandomName()
and getRandomColor()
functions as well as the MemberData
class itself.Download gta 5 for android full apk free. For the sake of keeping this tutorial simple, we'll define a random username on the client side of the application. Later you can add fancy login functionality to your app. To create a random name, we pre-define two lists of random adjectives and nouns, then combine them randomly.
The random color function will be generating a random seven-character color hex such as
#FF0000
.The
MemberData
class is super minimal and will later be serialized into JSON and sent to users by Scaledrone.Sending messages
To send (or publish) the message to the Scaledrone room we need to add a
onClick()
handler to the ImageButton
in the activity_main.xml
file.Let's add the
sendMessage()
function to the MainActivity
. If the user has input something we send the message to the same observable-room as we subscribed to above. After the message has been sent we can clear the EditText
view for convenience.Scaledrone will take care of the message and deliver it to everyone that has subscribed to the observable-room room in your channel.
Displaying messages
As seen in the layout file the messages are going to be displayed via
ListView
. To use a ListView
you need to create a class that extends android.widget.BaseAdapter
. This class is then used as the state of the ListView
.Let's define our
MessageAdapter
as well as the Message
class itself. The Message
class will hold all the needed info to render a single message.The
MessageAdapter
defines how we render our rows within the ListView
.Receiving messages
Now that we can display and render our chat bubbles we need to hook up the incoming messages with the
MessageAdapter
that we just created. We can do that by going back to the MainActivity
class and finishing the onMessage()
method.Scaledrone uses the popular Jackson JSON library for serializing and parsing the messages, and it comes bundled with the Scaledrone API client. Please see the Jackson docs for best practices on how to parse the incoming Scaledrone messages and users data.
And we're done!
Hopefully, this tutorial helped you build your very own chat app. You can find the full source code or run the working prototype on GitHub. If you have any questions or feedback feel free to contact us.
Top Chat Apps For Android
This tutorial only scratched what Scaledrone can do for you and is the ideal basis for any of your future realtime needs.
Looking to build the same app for iOS using Swift? Check out our iOS chat tutorial.
Download Go Chat App For Android Iphone
Last updated February 5th 2019. Now using Scaledrone client 0.6.0.