Describe the bug
When detecting that the location service is disabled on Android, before asking the user to enable it manually I call
final serviceActive = await Location().requestService();
This does not return a value regardless of if I enable the location service through the native dialog or if I just dismiss it.
Expected behavior
A value should return, reflecting whether or not the user enabled/disabled the location service
Tested on:
Other plugins:
permission_handler: ^5.0.1flutter doctor -v
[✓] Flutter (Channel stable, v1.17.4, on Mac OS X 10.15.5 19F101, locale en-GB)
• Flutter version 1.17.4 at /Users/michaelmccormick/development/flutter
• Framework revision 1ad9baa8b9 (7 days ago), 2020-06-17 14:41:16 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
• Android SDK at /Users/michaelmccormick/Library/Android/sdk
• Platform android-29, build-tools 29.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.5, Build version 11E608c
• CocoaPods version 1.9.2
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 46.0.1
• Dart plugin version 192.8052
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API
29) (emulator)
Any solution
Hi @Lyokone
any update on this?
Facing the same issue, any workaround?
I can't believe how many times this same issue has been reported for this package without a proper fix. xD
Is there something else that works?
Any update...
Any update...
i have same problem, why no fix for this.
I am facing the same issue using a physical device. This feature is also missing in Flutter Geolocator Plugin.
I have same issue on real device only (xiaomi mi9 tested only). And when i call requestService(), dialog appears on screen if i am pressing yes or no, dialog appears again, and do not return anything. Working fine on emulator.
@razmik-gharibyan For me once you press yes the dialog disappears but the function doesn't return anything so the app just gets struck
Somehow getLocation() method also opens dialog, if service is not enabled. If i press yes i see that location is ebabled on device, but function gets stuck, so try to add timeout on that function and when it's done you'll get timeout exception, so i catch that exception and i am calling getLocation() again and it give location. sad part is that you cant know when user will press yes or no so ur exception might come before user presses anything, so you'll have multiple dialogs opened one on another.
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects this solved my problem.
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects this solved my problem.
tried but not working
Samsung note 8, 24 August (location 3.0.2), same problem
anyone find a work around, or is a java dev that can help resolve this?
anyone find a work around, or is a java dev that can help resolve this?
Actually i've gave up. But then i find out that ,in order to get approved for appstore you should not request service by dialog, you should prompt user to location settings or just settings screen and user should enable location service manually. So i've done same implementation for android too. And i am using combinations of plugins such as geolocator,location,location_permissions
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Any solution