Compassly is a native Android compass application designed to demonstrate real-time device sensor integration, lifecycle-aware state management, and modern Jetpack Compose UI development. The app reads accelerometer and magnetic-field sensor data, converts the device heading into degrees and cardinal directions, and displays the result through a custom Compose compass interface.
A physical Android device is recommended for full compass testing because sensor availability and accuracy can vary by emulator and hardware.
This project was created to demonstrate native Android development skills, including sensor integration, Compose UI development, state management, lifecycle-aware logic, and unit testing.
- Real-time compass heading display
- Degree reading with cardinal direction label
- Direction formatter for North, Northeast, East, Southeast, South, Southwest, West, and Northwest
- Sensor availability handling
- Calibration message for low magnetic accuracy
- Jetpack Compose UI with a custom compass dial
- Lifecycle-aware sensor start and stop behavior
- Unit tests for direction formatting logic
- Kotlin
- Android SDK
- Jetpack Compose
- Material 3
- SensorManager
- StateFlow
- Android ViewModel
- JUnit
Compassly separates sensor handling, UI state, and presentation logic into clear layers:
SensorManager
↓
CompassSensorManager
↓
CompassViewModel
↓
CompassScreen
↓
Jetpack Compose UI
app/src/main/java/com/wadrien/compassly
├── MainActivity.kt
├── sensor
│ └── CompassSensorManager.kt
├── ui
│ ├── CompassScreen.kt
│ └── CompassViewModel.kt
└── util
└── DirectionFormatter.kt
The project includes unit tests for the direction-formatting logic.
Example tested behavior:
0° → N
45° → NE
137° → SE
270° → W
359° → N
- Clone the repository.
- Open the project in Android Studio.
- Allow Gradle to sync.
- Run the app on an Android emulator or physical Android device.

