48 lines
No EOL
1.6 KiB
Markdown
48 lines
No EOL
1.6 KiB
Markdown
# Traccar Client
|
|
|
|
Flutter Android app for background GPS location tracking, sending data to a Traccar server.
|
|
|
|
## Build
|
|
|
|
```bash
|
|
flutter build apk --debug
|
|
```
|
|
|
|
The APK is output to `build/app/outputs/flutter-apk/app-debug.apk`.
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
lib/
|
|
main.dart # App entry, dark theme, routing
|
|
main_screen.dart # Tracking toggle + live coordinates
|
|
permission_screen.dart # Pre-flight permission setup
|
|
settings_screen.dart # Server URL, device ID, accuracy config
|
|
status_screen.dart # Event log (LOCATION, SYNC, ERROR, etc.)
|
|
preferences.dart # SharedPreferences wrapper
|
|
bridge/
|
|
location_bridge.dart # Dart↔Native MethodChannel (com.traccar.client/tracking)
|
|
|
|
android/app/src/main/kotlin/com/traccar/traccar_client/
|
|
BridgeModule.kt # Method channel handler
|
|
service/LocationTrackingService.kt
|
|
location/HeartbeatScheduler.kt # AlarmManager heartbeat
|
|
network/TraccarHttpClient.kt # POST to server
|
|
network/ConnectivityReceiver.kt
|
|
```
|
|
|
|
## Configuration
|
|
|
|
On first launch, `PermissionScreen` guides through:
|
|
1. **Location** — `locationWhenInUse` then `locationAlways` (background)
|
|
2. **Notification** — required for tracking alerts
|
|
3. **Battery** — disable Doze optimization so tracking works reliably
|
|
|
|
Then set server URL and device ID in Settings before starting tracking.
|
|
|
|
## Server Request Format
|
|
|
|
POST to `https://yourserver/?id=DEVICE_ID&lat=...&lon=...×tamp=...&is_moving=0`
|
|
|
|
- `is_moving` = `speed > 1.0 m/s` (3.6 km/h threshold)
|
|
- Server URL and device ID come from `Preferences` (configured in Settings screen) |