Skip to content

An android chatting app made in compose which uses device Bluetooth for transferring data (chats) and follows MVVM architecture.

Notifications You must be signed in to change notification settings

sDevPrem/bluetooth-chat-mvvm

Repository files navigation

Bluetooth Chat

A simple chatting android app that uses bluetooth to connect with other devices and transfer chats. It is made in Jetpack Compose and follows MVVM Architecture for the flow of data.

Screenshots

home_screen chatting_screen

Features

  • Scan nearby bluetooth devices.
  • Pair with nearby devices.
  • Once paired, start chat with the paired device.

How to use

  1. Give the appropriate permission asked at startup.
  2. Open BluetoothChat app on both the devices and turn on bluetooth.
  3. Click on start server button in one of the device.
  4. On the other device, click on start scan.
    • If the device is paired it will be shown in the paired devices and clicking it will open the chat.
    • If not, wait for the scan and when the device appears below the scanned devices click and pair it. Upon pairing, you will be navigated to chatting screen.
  5. After completing the chat, click on the cross button at the top-right corner that will close the chat on both the devices.

Build With

Jetpack Compose : To build UI.
Android Bluetooth API : To connect devices and share data.
Kotlin Coroutines and Flow : For asynchronous programming.
Hilt : For dependency injection.

Architecture

  1. Client-Server architecture to transfer chats from one device to another
  2. MVVM (Model-View-ViewModel) architecture.
  3. UDF (Unidirectional Data Flow) Pattern.

Classes And Roles

  • AndroidBTController
    • Get Paired devices
    • To start and stop scans for new bluetooth devices
    • To connect and disconnect bluetooth devices
  • BTDataTransferService
    • To send messages
    • Listen for incoming messages