Baseflow / flutter-geolocator

Android and iOS Geolocation plugin for Flutter
https://baseflow.com/
MIT License
1.24k stars 653 forks source link

[Android] Nagging dialogue when "Google Location Accuracy" is turned off. #1210

Open simtr opened 1 year ago

simtr commented 1 year ago

🐛 Bug Report

On a phone with "Google Location Accuracy" turned off, invoking any method to request location updates causes a system dialog to be displayed on the screen, over the app.

image "To continue, turn on device location, which uses Google's location service" with the options "No, thanks" and "OK".

Pressing "No, thanks" will dismiss the dialog and location updates will work as normal, but any future calls for location updates triggers the same dialog over and over again with no apparent way to permanently dismiss

It appears to be triggered by this line of code: https://github.com/Baseflow/flutter-geolocator/blob/e60daab16c5568ee46ff3c8851b16167c3e412e9/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/FusedLocationClient.java#L227

Some debugging shows that despite location permissions being granted, and the GPS services turned on, the addOnFailureListener is called with a ResolvableApiException insisting that a related, but not required, service be enabled.

Expected behavior

Users should not see this dialog at all, it's not related to the app's location permission, nor is it a requirement to receive location updates.

Reproduction steps

Navigate into the device settings, find the "Location Services" options for the phone and disable "Google Location Accuracy", while leaving the actual "Location" service enabled.

Reuqest COARSE_LOCATION and FINE_LOCATION in your manifest, install the app and manually grant the location permissions through the app's settings page.

Make any request for locations, eg: Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.best)

Configuration

Version: 9.0.2

Platform:

yangsfang commented 1 year ago

I'm having this problem. But more severe. getCurrentPosition() actually fails, because this package mistakes Location is turned off, if "Google Location Accuracy" is disabled on my Android 12 (API 31) test device, despite Location is turned on and Google Maps successfully getting position from GPS. (The same as your testing condition, except the result is a failure rather than nagging)

I'm just using the example project in this repo for testing. Version 9.0.2, Android API 31.

vanlooverenkoen commented 1 year ago

I am having the same issue indeed. At first glance all our Samsung test devices had this issue. But after turning the setting off. all our test devices had this issue

Myzel394 commented 1 year ago

I'm also facing this issue

CoolMind commented 10 months ago

It appears to be triggered by this line of code:

https://github.com/Baseflow/flutter-geolocator/blob/e60daab16c5568ee46ff3c8851b16167c3e412e9/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/FusedLocationClient.java#L227

@simtr thank you! I copied startPositionUpdates method to create this Google dialog in Kotlin. In Compose see https://stackoverflow.com/questions/68693895/how-to-observe-onactivityresult-in-jetpack-compose.

KonradSzymanskiMoodUp commented 4 days ago

any solution here?