Chitter – Android chat application
The aim of this project was to learn how a chat application works in terms of communication between a client and server. While developing the project, both team members learnt about topics that they were unfamiliar with such as REST APIs, asynchronous programming and how to sync data between a local and remote database. The project allowed both team members to work on their current programming skills in PHP, MySQL, Java and XML.
Chitter is a messaging application built for Android devices. It allows users to send and receive messages over an internet connection in real time. The application uses a client server model. The client side of the project is built as an Android application, which uses the programming languages Java and XML. The client application connects to a REST API on the application server, which exposes the application servers’ resources such as the database tables. The REST API was built on top of a micro framework called Slim. The REST API has been written in PHP, while the servers database is a MySQL database. There are two ways of storing data for the application, using either a centralised or distributed database. Centralised is when all the data is stored within a database on the server, while distributed is when all the data is stored in a local database on each of the client devices. Chitter uses a hybrid of these two choices, meaning the data gets stored on the server as well as on each of the Android (client) devices. The database stored on the client device is a subset of that stored on the application server and only contains data for that specific user. The type of database which is used on an Android device is an SQLite database. It is necessary for the client and server databases to be kept in sync. This is so that, when messages are sent to the client while offline, the messages will be received when the client regains an internet connection. This is done in a different process than the client application, using Android’s SyncAdapter framework. To send messages to each of the clients, the REST API sends a request to the Firebase Cloud Messaging (FCM) server using CURL. The FCM server then sends message data to the client. The client processes the data received from the FCM server in a background thread to avoid blocking the UI thread, which in turn provides a smooth user experience. The client application follows Google’s Material Design guidelines, which is used to help design a UI that users find more enjoyable and easy to use.
This project helped us obtain an understanding of how a client and server interact with each other to create a working chat application. To do this, we learned how to create a REST API, which helped us access specific resources from the database. We also learned about content providers, which are used to manage access to an Android database, loaders, which load data from queried by the content provider in a background thread and CURL, which is used to send requests from the application server to the FCM server.