Comments (5)
@mikejeep This should be fixed in version 0.1.7. Please upgrade the dependency to this version and it should work fine.
from android-permissions.
The scenario where a permission dialog is being shown and another permission is asked later is explicitly handled by the library and another permission dialog gets stacked up for the latter permission. However, in specific cases where the shown dialogs do not get user input and are leaked due to their parent context getting destroyed (in case the hosting Activity gets destroyed), the library does not recognize and hence it believes the permissions are still pending.
While this can be handled if the lifecycle is being handled properly in the app using the library, it makes sense for the library to also have the capability to know about the dialogs not being shown anymore. I will see how difficult that is and will update on if it can be handled.
Thanks for reporting the behavior!
from android-permissions.
I actually may have found the cause of the issue. In my app's manifest, I used launchMode=singleInstance
. When changing that to any other option, the permission prompts from your library appear to stack properly. I need to do more testing to determine if that otherwise negatively impacts my app, but that appears to be a caveat you may want to document for other users.
from android-permissions.
@mikejeep Thanks for spending time on this and figuring out the cause. This is a good finding.
I tried this on a minimal app and was able to reproduce the issue.
I am not sure why launchMode=singleInstance
will cause this but on doing a bit of research I realized that it should have never worked for showing multiple permission dialogs stacked up (even without the launchMode). The permission dialog is supposed to be shown in a new task but how to show another dialog if another request is made is not handled explicitly. So multiple dialogs were being shown when launchMode=singleInstance
was absent due to some implicit handling by android. When the launchMode
is present, it works as documented in Android documentation.
The good thing is that now that we know the exact cause, multiple solutions could be tried out. I will spend some time today to fix this. It should then work for your application without changing the launchMode
.
from android-permissions.
@mikejeep So the exact cause of the issue was at the place where the activity that contains permission dialog(s) was being started.
Whenever a permission is requested, a PermissionActivity
is started using FLAG_ACTIVITY_NEW_TASK
flag. According to the documentation, while starting an activity with this flag, it searches for all existing tasks for an activity that has intent matching this intent and only if no matching activity is found is when a new task is created for new activity. However, if no taskAffinity
is provided for this activity, it is not created in a new task, which was the case here.
When launchMode=singleInstance
is provided, any new activity started from there has to start in a new task and that's where the actual documented behavior for FLAG_ACTIVITY_NEW_TASK
is noticed. The intent for new permission activity remained same with just different extras
due to which it brought back the same task in front without starting another activity.
An immediate solution for this is to make the intents different for different permission requests (different IntentAction would work) which is what I have done for now, but I have a few things in mind which I would implement soon to make this more stable (possibly without the need of starting new tasks).
from android-permissions.
Related Issues (20)
- How to grant multiple permissions at once in singleton place. HOT 1
- application@allowBack is required by the plugin HOT 5
- Can't add dependency HOT 2
- Question: Is this library published? HOT 3
- How do i test from Activity for onPermissionDenied() it cannot be invoked. i cannot make an object of PermissionHandler class HOT 3
- Notification channel not registered on API27 HOT 1
- New Location Permissions Scheme for Android Q HOT 5
- Switch to AndroidX HOT 2
- Logging occasional ConcurrentModificationException errors HOT 12
- error: Landroidx/localbroadcastmanager/content/LocalBroadcastManager, dependency missing HOT 1
- Callbacks not working in foreground service HOT 6
- Using FLAG_ACTIVITY_NEW_TASK instead of notification
- Project should be moved off jcenter repository HOT 14
- NPE on runningAppProcesses iterator() in AppStatus.isInForeground() method HOT 7
- Crash when permissions denied HOT 3
- Api not adjusted to android-31 target. HOT 6
- [Updated] The library is still a live!! thank you @nishkarsh HOT 7
- Add ability to provide custom/app icon for the status bar notification HOT 2
- Allow using a high priority / important notification HOT 1
- Add ability to set color of notification HOT 2
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 android-permissions.