-
-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: In Android 11 not able to fetch long in background #1588
Comments
I'm experiencing the same. If I provide a
I don't know if it really means your call would wait for minutes to receive a position really. I can fall back to Future<Position?> _getPosition({
required LocationSettings settings,
required bool fallbackToLastKnownLocation,
}) async {
try {
return await Geolocator.getCurrentPosition(locationSettings: settings);
} on TimeoutException {
if (fallbackToLastKnownLocation) {
return Geolocator.getLastKnownPosition(
forceAndroidLocationManager: settings is AndroidSettings
? settings.forceLocationManager
: false,
);
}
rethrow;
}
} However setting the |
After some testings I have some new observations:
PS: Starting a foreground service would solve the issue, but I think we are talking about one-off request cases here when that is not feasible. |
Please check the following before submitting a new issue.
Please select affected platform(s)
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<Position?> _determieOffline() async {
late LocationSettings locationSettings;
locationSettings = AndroidSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 100,
forceLocationManager: true,
intervalDuration: const Duration(seconds: 10),
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 ~ %
The text was updated successfully, but these errors were encountered: