flutter_background_geolocation
flutter_background_geolocation copied to clipboard
[Bug]: I am constantly tracked even though I have stopped moving.
Required Reading
- [x] Confirmed
Plugin Version
flutter_background_geolocation: ^4.18.1
Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 3.27.3, on macOS 15.3.1 24D70 darwin-arm64, locale en-VN)
! Flutter version 3.27.3 on channel [user-branch] at /Users/phananhduc/development/flutter
Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
! Upstream repository unknown source is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.97.2)
[✓] Connected device (5 available)
! Error: Browsing on the local area network for Samsung 10 tạ ló. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
Mobile operating-system(s)
- [ ] iOS
- [x] Android
Device Manufacturer(s) and Model(s)
Samsung A53, Samsung galaxy s24
Device operating-systems(s)
Android 14
What happened?
When I upgraded to the latest version of flutter_background_geolocation, I encountered a situation where even though I stopped moving the device, motion was changed to false, but then motion was changed to true and continued tracking, which consumed a lot of battery and the user was tracked 24/7 even though he didn't move at all. You can see my log file:
flutter_background_geolocation.docx
Plugin Code and/or Config
Future<void> initializeModeNormal(int confidence) async {
try {
// Đăng ký các sự kiện
bg.BackgroundGeolocation.onLocation(_onLocation, _onLocationError);
bg.BackgroundGeolocation.onMotionChange(_onMotionChange);
bg.BackgroundGeolocation.onActivityChange(_onActivityChange);
bg.BackgroundGeolocation.onProviderChange(_onProviderChange);
bg.BackgroundGeolocation.onHeartbeat(_onHeartbeat);
// Cấu hình tối thiểu cho Background Geolocation
bg.BackgroundGeolocation.ready(bg.Config(
debug: false,
logLevel: bg.Config.LOG_LEVEL_VERBOSE,
desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
stopTimeout: 2,
distanceFilter: 5,
activityRecognitionInterval: 1000,
disableElasticity: false,
locationUpdateInterval: 3000,
fastestLocationUpdateInterval: 3000,
geofenceModeHighAccuracy: true,
autoSync: false,
minimumActivityRecognitionConfidence: confidence,
activityType: bg.Config.ACTIVITY_TYPE_OTHER_NAVIGATION,
// minimumActivityRecognitionConfidence: 60,
// activityType: bg.Config.ACTIVITY_TYPE_OTHER_NAVIGATION, IOS ONLY
stopOnTerminate: false,
notification: bg.Notification(
title: "GreenMove",
text: 'Service de localisation activé',
channelName: "Détection d'Activité",
),
startOnBoot: true,
enableHeadless: true,
persistMode: bg.Config.PERSIST_MODE_NONE,
heartbeatInterval: 150,
// pausesLocationUpdatesAutomatically: false,
backgroundPermissionRationale: bg.PermissionRationale(
title:
"Autoriser {applicationName} à accéder à la localisation de cet appareil.",
message:
"L'application vous aide à gérer et à enregistrer vos trajets de manière pratique.",
positiveAction: 'Toujours autoriser',
negativeAction: 'Annuler')))
.then((bg.State state) async {
if (!state.enabled) {
await bg.BackgroundGeolocation.start();
}
}).catchError((error) {});
} catch (e) {
rethrow;
}
}
Relevant log output
You can see my log file:
https://docs.google.com/document/d/1DQI1z2mfjnEwfJNQ4siHYtSqeMYZBMGQrI80qwdX2W4/edit?usp=sharing
@christocracy