Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with stack rationale dialog #193

Closed
mgolebiowski95 opened this issue Jan 9, 2018 · 13 comments
Closed

Problem with stack rationale dialog #193

mgolebiowski95 opened this issue Jan 9, 2018 · 13 comments

Comments

@mgolebiowski95
Copy link

mgolebiowski95 commented Jan 9, 2018

Basic Information

Device type: ________
OS version: ________
EasyPermissions version: 1.0.1

Describe the problem

What happened? What did you expect to happen?

When I executed code below code 0 in onStart() every time show new rationale dialog over previous dialog. If dialog is exist new dialog should'nt show. A good solution would be to add a method that checks whether or not a rationale dialog is shown code 1 and code 2

Code and logs

code 0:
EasyPermissions.requestPermissions(this,
"To function properly, App needs your permissions. Allow permissions for App",
RC_REQUIRED_PERM,
REQUESTED_PERMISSIONS_ON_START);

code 1:

1

code 2:

2

// TODO(you): show the code that produces the problem,
execute code 0 in onStart() ex. go to background and returning to application more than 1 time

@samtstern
Copy link
Contributor

@mgolebiowski95 can you show your onStart method?

@mgolebiowski95
Copy link
Author

3

@mgolebiowski95
Copy link
Author

or run this code and change orientation a few times

@mgolebiowski95
Copy link
Author

my requested permisison
4

@mgolebiowski95
Copy link
Author

mgolebiowski95 commented Jan 10, 2018

You can too add to library method checking android permission dialog is actually showing. In onCreate() bundle savedInstanceState key="android:hasCurrentPermissionsRequest" which contains this value.

@mgolebiowski95
Copy link
Author

I found quite accidentally :-)

@mgolebiowski95
Copy link
Author

5

@samtstern
Copy link
Contributor

@mgolebiowski95 huh that's a cool tip about android:hasCurrentPermissionsRequest. Thanks!

Can you show the crash logs you're getting? Also is your Activity a descendant of AppCompatActivity?

@mgolebiowski95
Copy link
Author

mgolebiowski95 commented Jan 11, 2018

I hadn't crash. This is my simple test https://github.com/mgolebiowski95/easypermissionstest. (master, another_idea)

problem: stack rationale dialog

  • clear application data -> grand first permission, other deny -> close appsetting dialog -> rotate phone a few times / go to background and return to app

  • clear application data -> grand first permission, other deny -> rotate phone a few times / go to background and return to app (rationale dialog stack under appsetting dialog)

Maybe AppSetting Dialog better create based on DialogFragment. Then can check findFragmentByTag is exists.

With android:hasCurrentPermissionsRequest may be problem. When go to background and return to app onCreate() isn't called (only onStart() and onResume() ) and can not update value hasCurrentPermissionsRequest. (there is no access to savedInstanceState bundle)

@samtstern
Copy link
Contributor

@mgolebiowski95 thanks for the code, I can confirm that in your situation the dialog does stack. There are two action items here:

  • This library should make an attempt to not show the rationale dialog if one is already showing.
  • Your app probably should not show the dialog on onStart, the Android UX guidelines for permissions
    requests say to show the request in response to a user action (button click, etc)

@samtstern
Copy link
Contributor

#195 will fix this issue

@samtstern samtstern added this to the 1.1.2 milestone Jan 11, 2018
@samtstern
Copy link
Contributor

This issue has been fixed and released in version 1.1.2

@LolWalid
Copy link

I have a similar bug in version 1.2.0 and not in 1.1.2.

Looks like easypermission is keeping reference to the Fragment after rotation

But I don't get why if I rotate only once, it doesn't crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants