Baseflow / Baseflow/flutter-geolocator
[Bug]: In Android 11 not able to fetch long in background
- Dominant language
- Dart
- Stars
- 1.3k
- Forks
- 803
- Avg merge
- 8h 16m
- Merged PRs (30d)
- 1
Description
### Please check the following before submitting a new issue.
- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [X] I have carefully [read the documentation](https://github.com/Baseflow/flutter-geolocator/blob/main/geolocator/README.md) and verified I have added the required platform specific configuration.
### Please select affected platform(s)
- [X] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows
### Steps to reproduce
In Android 11 not able to fetch long in background
### Expected results
to get lat long when app in background
### Actual results
in background not response and no log producing
### Code sample
@pragma('vm:entry-point')
Future _determieOffline() async {
late LocationSettings locationSettings;
locationSettings = AndroidSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 100,
forceLocationManager: true,
intervalDuration: const Duration(seconds: 10),
foregroundNotificationConfig: const ForegroundNotificationConfig(
notificationText:
"Example app will continue to receive your location even when you aren't using it",
notificationTitle: "Running in Background",
enableWakeLock: true,
));
print("before get current position");
Position? position;
try {
position =
await Geolocator.getCurrentPosition(locationSettings: locationSettings);
} catch (e) {
print("the error geooffline is $e");
}
return position;
}
### Screenshots or video
Screenshots or video demonstration
[Upload media here]
### Version
geolocator: ^13.0.1
### Flutter Doctor output
lb@LBs-MacBook-Pro ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0 24A335 darwin-x64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.94.1)
[✓] Connected device (4 available)
[✓] Network resources
• No issues found!
lb@LBs-MacBook-Pro ~ %
Contributor guide
Research direction
Start with the Android 11 reproduction described in the issue and the _determieOffline entry point, then review the geolocator README's Android background-location configuration. Verify whether getCurrentPosition returns or logs when the app is backgrounded with the shown AndroidSettings and foreground notification configuration. Done means the reported background behavior is reproduced and a confirmed cause or maintainable fix is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, dart, flutter
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100