flutter-permission-handler
flutter-permission-handler copied to clipboard
locationAlways in android 12
calling Permission.locationAlways.request()
doesn't show anything in android 12
Same problem
+1 recently
Really nothing? Is this package even still under maintenance? This is a serious issue
seems fixed in 9.0.1
p.s : i test it, but not solved this problem yet
9.1.0: API 31 (Android 12) - The issue is still present; API 30 (Android 11) - Fixed;
Same problem!
Try replacing below permission
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
With
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="31" tools:replace="android:maxSdkVersion" />
The same issue I have but in Android 11. @anilthapa1939 your solution does not work at least to me.
Scrolling through changelogs I found an entry mentioning a section in the readme detailing that to request locationAlways, you have to request locationWhenInUse first. When doing that on Android 12, things "work". After the initial popup of the location permission for while the app is in use, the app's location settings are opened.
It also seems like requesting locationAlways again after that (even if the user accepted them) will reopen the settings which isn't ideal.
We really need a fix for the location. When we ask for precise location we only get approximated but our app needs the precise location
@Kampfotter did you used the accuracy: Location.navigation option in changeSettings? I think the default accuracy is enough, and your issue should be asked in flutter plugins .
Hi everyone, thank you for reporting this issue.
I have investigated the issue, and there are some intricacies with Android starting from Android 10: https://developer.android.com/training/location/permissions#request-only-foreground.
It boils down to this: before you can request Permission.locationAlways
, you need to obtain a foreground location permission via either Permission.location
or Permission.locationWhenInUse
. This has been described in the plugin in permissions.dart
:
/// Permission for accessing the device's location when the app is running in
/// the background.
///
/// Depending on the platform and version, the requirements are slightly
/// different:
///
/// **Android:**
/// - When running on Android Q and above: Background Location Permission
/// - When running on Android < Q: Fine and Coarse Location
///
/// **iOS:** CoreLocation - Always
/// - When requesting this permission, the user needs to grant permission for
/// the `locationWhenInUse` permission first, clicking on the
/// `Allow While Using App` option on the popup. After allowing the
/// permission, the user can request the `locationAlways` permission and can
/// click on the `Change To Always Allow` option.
static const locationAlways = PermissionWithService._(4);
I think the documentation could use some work, because it is quite hard to find. Therefore, I have opened PRs #1133 and #1134. These should update both the documentation and add a section to the FAQ over on pub.dev.