In this tutorial, you'll explore Animal Forest Chat, a simple, yet feature-rich Android chat app with Java and PubNub. Your app will run on Android Phone, using PubNub as the messaging infrastructure and framework to connect your chat users.
Download the code
You can get the full source code from GitHub. The code for this tutorial is in the
This tutorial requires the Presence and Storage & Playback add-ons. Refer to Create a PubNub app for detailed instructions.
A PubNub account. Sign up for PubNub and manage your projects from the Admin Dashboard.
Android Studio. If you don't have Android Studio installed, you can download it from the Android Developers site.
PubNub Java SDK. Refer to Set up your project for instructions on how to install the PubNub SDK.
Create a PubNub app
To create and configure a PubNub app for this tutorial, do the following:
Sign in to your PubNub Admin Dashboard, click Create New App, and give your app a name.
Select your new app, then click its keyset. Copy the Publish and Subscribe keys. You'll need these keys to include in your project.
Scroll down on the Key Options page and enable the Presence and Storage & Playback add-on features.
Click Save Changes, and you're done!
Run the project
To run the application in your local environment, do the following:
Follow the instructions in Using your PubNub keys to set up a
gradle.propertieswith your keys in it.
Launch Android Studio. On the welcome screen, choose Open an existing Android Studio project.
Select the root project folder,
chat-examples-java/, and click Open.
Wait for Gradle to download dependencies and sync the project. This could take several minutes.
Choose Run > Run 'app', and pick the device on which you want to run the app.
(If necessary, create a new virtual device on which to run the app.)
Explore the code
That's it! You should now have the app running in your local environment. To learn how we built the chat application, have a look at the Android walkthrough.
To learn more, the reference section in the documentation includes code snippets for advanced features like typing indicators, unread message counts, security controls, chatbots, and more.