Comments (4)
Dear @lukehutch,
Unfortunately, this is a known edge case. How it works is explained in the documentation:
I'll close this issue for now, feel free to reopen the issue if new information pops-up.
/**
* Returns a {@link PermissionConstants} for a given permission.
* <p>
* When {@link PackageManager#PERMISSION_DENIED} is received, we do not know if the permission was
* denied permanently. The OS does not tell us whether the user dismissed the dialog or pressed
* 'deny'. Therefore, we need a more sophisticated (read: hacky) approach to determine whether the
* permission status is {@link PermissionConstants#PERMISSION_STATUS_DENIED} or
* {@link PermissionConstants#PERMISSION_STATUS_NEVER_ASK_AGAIN}.
* <p>
* The OS behavior has been researched experimentally and is displayed in the following diagrams:
* <p>
* State machine diagram:
* <p>
* Dismissed
* ┌┐
* ┌──┘▼─────┐ Granted ┌───────┐
* │Not asked├──────────►Granted│
* └─┬───────┘ └─▲─────┘
* │ Granted │
* │Denied ┌───────────┘
* │ │
* ┌─▼────────┴┐ ┌────────────────────────────────┐
* │Denied once├────────►Denied twice(permanently denied)│
* └──▲┌───────┘ Denied └────────────────────────────────┘
* └┘
* Dismissed
* <p>
* Scenario table listing output of
* {@link ActivityCompat#shouldShowRequestPermissionRationale(Activity, String)}:
* ┌────────────┬────────────────┬─────────┬───────────────────────────────────┬─────────────────────────┐
* │ Scenario # │ Previous state │ Action │ New state │ 'Show rationale' output │
* ├────────────┼────────────────┼─────────┼───────────────────────────────────┼─────────────────────────┤
* │ 1. │ Not asked │ Dismiss │ Not asked │ false │
* │ 2. │ Not asked │ Deny │ Denied once │ true │
* │ 3. │ Denied once │ Dismiss │ Denied once │ true │
* │ 4. │ Denied once │ Deny │ Denied twice (permanently denied) │ false │
* └────────────┴────────────────┴─────────┴───────────────────────────────────┴─────────────────────────┘
* <p>
* To distinguish between scenarios, we can use
* {@link ActivityCompat#shouldShowRequestPermissionRationale(Activity, String)}. If it returns
* true, we can safely return {@link PermissionConstants#PERMISSION_STATUS_DENIED}. To distinguish
* between scenarios 1 and 4, however, we need an extra mechanism. We opt to store a boolean
* stating whether permission has been requested before. Using a combination of checking for
* showing the permission rationale and the boolean, we can distinguish all scenarios and return
* the appropriate permission status.
* <p>
* Changing permissions via the app info screen, so outside of the application, changes the
* permission state to 'Granted' if the permission is allowed, or 'Denied once' if denied. This
* behavior should not require any additional logic.
*
* @param activity the activity for context
* @param permissionName the name of the permission
* @param grantResult the result of the permission intent. Either
* {@link PackageManager#PERMISSION_DENIED} or {@link PackageManager#PERMISSION_GRANTED}.
* @return {@link PermissionConstants#PERMISSION_STATUS_GRANTED},
* {@link PermissionConstants#PERMISSION_STATUS_DENIED}, or
* {@link PermissionConstants#PERMISSION_STATUS_NEVER_ASK_AGAIN}.
*/
from flutter-geolocator.
I am also facing this problem.
from flutter-geolocator.
Permission.location.status may instead be used.
from flutter-geolocator.
@TimHoogstrate How about adding one additional catch-all -- that if Geolocator.requestPermission()
returns within some short period of time (e.g. 100ms), then the status is set to permanently denied?
Actually it would be great if Geolocator
could distinguish between "known permanently denied" (if Geolocator.requestPermission()
returns immediately) and "may be permanently denied"...
from flutter-geolocator.
Related Issues (20)
- [Bug]: Crash on Android 6.0 POS Device HOT 5
- [Bug]: Crashes because of dereferencing undefined (navigator.geolocation) HOT 2
- [Bug]: LocationSettings timeLimit not work HOT 5
- [Question]: I want to get position update when app run in background, what should I do? HOT 2
- [Bug]: Channel sent message from native to Flutter on a non-platform thread. HOT 1
- [Bug]: the operation couldn’t be completed. (kCLErrorDomain error 1.) HOT 10
- [Bug]: Build error with version 11.0.0 HOT 4
- [Bug]: Crash when calling checkPermission/requestPermission on Windows with Geolocation Service disabled. HOT 3
- [Bug]: Geolocator has conflict with Safe Device package HOT 2
- [Question]: The AndroidSettings's intervalDuration property cannot work and when the app running in the background, the app will be terminated. How can I do? HOT 6
- Junior AI: Real-time Location Tracker Application
- [Question]: is there a way to read each GPS satellite signal individually? or any code examples? Thanks. HOT 1
- [Bug]: requestPermission() returns LocationPermission.always but checkPermission() LocationPermission.denied HOT 2
- [Regression]: ERROR WHILE ADD PACKAGE IN PUB FILE HOT 1
- [Bug]: HOT 3
- [Bug]: kCLErrorDomain error 1. on Background (BYPASS_PERMISSION_LOCATION_ALWAYS=1 not working) HOT 1
- [Bug]: Min API version should not be bumped to 34 until Sept 1 HOT 5
- Privacy manifest file in gelocator_apple 2.3.7 and update status of geolocator plugin HOT 2
- [Bug]: Subscribe to getServiceStatusStream throw an exception on Android 14 HOT 12
- [Feature Request]: Reading altitude from NMEA messages not only from the GPS system HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-geolocator.