Android application to track the user's location in real time developed in Kotlin with Jetpack Compose, following the MVVM architecture.
The app uses a Foreground Service to ensure continuous collection of location data, even when the app is in the background. It records metrics such as start date, duration, average speed, distance, steps, and distance traveled, storing each session locally in Room. Google Maps is used to display the route in real time.
- Activity Log: Start and stop tracking sessions with a single tap.
- Real-Time Metrics: View duration, speed, distance traveled, and steps as you move (step tracking does not work in the emulator).
- Map View: Follow your current route on an integrated Google Maps map.
- Background Tracking: Using a
Foreground Service
, the app continues recording your activity without having the app in the foreground. - Notification Control: Stop tracking directly from the foreground service notification, without having to open the app.
- GPS Check: Detects if the device's location is enabled at all times using a
Broadcast Receiver
. - Session History: Access a complete list of all your sessions saved in the local database.
The project follows an MVVM (Model - View - ViewModel) architecture, separating responsibilities into different layers to improve code scalability, testability, and maintainability.
Component | Technology |
---|---|
UI | Jetpack Compose |
Architecture | MVVM & Clean Architecture |
Dependency Injections | Hilt |
Service & Receiver | Foreground Service & BroadcastReceiver |
Local Storage | Room |
Maps | Google Maps SDK for Android |
Image Loading | Coil |
Navigation | Compose Navigation |
The app is structured into four main layers: Data, Domain, UI and Service.
.
├── data
│ ├── local
│ │ ├── dao
│ │ ├── entity
│ │ └── relation
│ ├── permissions
│ └── repository
│
├── domain
│ ├── model
│ ├── permissions
│ └── repository
│
├── ui
│ ├── navigation
│ ├── screens
│ ├── theme
│ └── utils
│
└── service
- Data: Contains the data access logic.
local
: Room database (dao
,entity
,relation
).permissions
: Concrete implementation for handling Android permissions (location, notifications).repository
: Implementation of the repositories that abstract data access.
- Domain: Contains the business rules of the application.
model
: Business logic data models.permissions
: Interfaces and models for permission management.repository
: Interfaces that define the contracts for the data layer.
- UI: Interface with Jetpack Compose.
navigation
: Navigation handling with Compose.screeens
: Contains each screen with itsViewModel
and theBroadcastReceiver
for checking GPS status.theme
: Definitions of colors, typography, and styles.utils
: UI Utilities.
- Service: Module dedicated to the
Foreground Service
that manages location tracking.- Contains the service implementation and its Hilt dependency injection module.
- Clone this repository.
- Open the project in Android Studio.
- Set up your Google Maps API key:
- Get an API key from Google Cloud Console.
- Add it to your
local.properties
file:MAPS_API_KEY=your_api_key_here
- Sync the project and run it on an Android device or emulator.
Daniel Frías - danielfb2312@gmail.com - LinkedIn Profile