Flutter-geolocator: Allow only while using the app in android 10 returns GeolocationStatus.denied

Created on 3 Oct 2019  ·  37Comments  ·  Source: Baseflow/flutter-geolocator

🐛 Bug Report

when selecting Allow only while using the app the new option in Android 10 Geolocator().checkGeolocationPermissionStatus() returns GeolocationStatus.denied
Screenshot_1570103723

Version: 5.1.4

Platform:
:robot: Android

android in progress

Most helpful comment

I have this same issue if using version 5.1.4+1 and compiling with SDK 28. If I compile on SDK 29 it works. Running this on a Pixel 3a running Android 10.

I can confirm that setting compileSdkVersion and targetSdkVersion to 29 resolved this issue.

All 37 comments

Could you tell me more about the code that returns GeolocationStatus.denied?

I can reproduce it with the sample app.
just try it with an android 10 emulator.

Does the emulator solve the GeolocationStatus.denied error?

I'm not sure I understand what you mean

Could you tell me some details about the code and what you are trying to create? I am trying to reproduce your issue, but I need more information.

try the demo app on an android emulator with android 10
untitled

I reproduced this issue and came to the conclusion that the location settings from the device were turned off. To fix this issue go to Settings>Location>Use Location>On.

the location was turned on I checked it, hence when I choose allow all the time it recognized as granted.

untitled

The output of the app says you are using FusedLocationProvider. It's recommended to use Google Play services version 11.6.0 or higher, which includes bug fixes for this class.

https://imgur.com/a/egX6z6t

As you can see I'm using google play services 19.2.75 and the location is on

Its a completely new permission in the new Android 10. it should neither give Allowed or Denied since it requires different checks.

https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_BACKGROUND_LOCATION

@humazed What are you trying to achieve with the Geolocator().checkGeolocationPermissionStatus() method? I don't get any errors if I set the location settings to Allowed all the time.

I use it for permission check, and even the demo app uses it and it doesn't work.
And the problem only appears when you choose to allow only while using the app

On Thu, Oct 10, 2019 at 10:09 AM Stijn van Woerkom notifications@github.com
wrote:

@humazed https://github.com/humazed What are you trying to achieve with
the Geolocator().checkGeolocationPermissionStatus() method? I don't get any
errors if I set the location settings to Allowed all the time.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/BaseflowIT/flutter-geolocator/issues/334?email_source=notifications&email_token=ACDNYJTFXDG2QBXZGR24XQTQN3PLPA5CNFSM4I5CDEP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEA3KOBY#issuecomment-540452615,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACDNYJS7PSSNNQPH3S7HBWTQN3PLPANCNFSM4I5CDEPQ
.

@humazed I reproduced the demo app in the new Android 10 and with the Geolocator().checkGeolocationPermissionStatus() method and retrieved 0 errors when I choose to allow only while using the app. Could you send your code so I could take a look at it?

I just cloned the repo and ran it without any changes

I even created a new emulator in case my current one has a problem or something but getting the same behavior

I think the issue would depend more on the settings from the emulator. The app states that there are issues with Google Play Services. Are you using a network or are you at a location that does not support the Google Play Services?

I have tried with a fresh emulator but the problem is the same

The app works fine for any version lower than android10

In the gifs I provided I'm showing the version of Google play services and the the location is enabled

I have this same issue if using version 5.1.4+1 and compiling with SDK 28. If I compile on SDK 29 it works. Running this on a Pixel 3a running Android 10.

I have this same issue if using version 5.1.4+1 and compiling with SDK 28. If I compile on SDK 29 it works. Running this on a Pixel 3a running Android 10.

I can confirm that setting compileSdkVersion and targetSdkVersion to 29 resolved this issue.

I have the same issue.

I see that with iOS too. getCurrentPosition() shows dialog box to enable location always or enable location while using the app or deny location access. Selecting "Enable while using the app" results in an exception with an error "PERMISISON_DENIED"

I am using geolocator 5.1.3

A similar error is reproduced on Pixel 4.

Same issue.
Samsung Galaxy S10 Plus, when click on "Keep while-in-use access" get PermissionStatus.denied

We are currently working on a new version of the location permissions plugin. This new version includes respected while-in-use access and no longer returns PermissionStatus.denied.

Urgh - I just discovered that I am experiencing the same issue for a production app. I had wrongly assumed that when a user gives in-use access permissions, this method would return PermissionStatus.granted - so I can no longer rely on this it seems.

EDIT: Two hours later, read the rest of the thread and realised that the suggestion of "I can confirm that setting compileSdkVersion and targetSdkVersion to 29 resolved this issue." works.

"I can confirm that setting compileSdkVersion and targetSdkVersion to 29 resolved this issue." solved the issue until I added this in the AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

@JBBx2016 We are working on the android.permissions.ACCES_BACKGROUND_LOCATION permissions. When the permissions are fixed, it could solve your error.

Any update?

any update?

Any Update

Not working on Android 10 devices. :|

As a temporary workaround, you can use my fork
branch Master
where I moved permission stuff from obviously broken location_permissions to another plugin permission_handler

My app just stop working after Google Play service PopUp, what ever i answer "Deny" , "Authorize", etc. with Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
and with best it works fine
Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.best);
Android 10 with emulator, latest stable branch flutter.

Geolocator locator = Geolocator();
    locator
        .checkGeolocationPermissionStatus(
            locationPermission: GeolocationPermission.locationWhenInUse)

Need to pass permission in params.
GeolocationPermission.locationWhenInUse

Fixed in version 6.0.0

Was this page helpful?
0 / 5 - 0 ratings