googlesamples / easypermissions

Simplify Android M system permissions
https://firebaseopensource.com/projects/googlesamples/easypermissions/
Apache License 2.0
9.87k stars 1.45k forks source link

Problem with stack rationale dialog #193

Closed mgolebiowski95 closed 6 years ago

mgolebiowski95 commented 6 years ago

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 commented 6 years ago

@mgolebiowski95 can you show your onStart method?

mgolebiowski95 commented 6 years ago

3

mgolebiowski95 commented 6 years ago

or run this code and change orientation a few times

mgolebiowski95 commented 6 years ago

my requested permisison 4

mgolebiowski95 commented 6 years ago

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 commented 6 years ago

I found quite accidentally :-)

mgolebiowski95 commented 6 years ago

5

samtstern commented 6 years ago

@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 commented 6 years ago

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

problem: stack rationale 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 commented 6 years ago

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

samtstern commented 6 years ago

195 will fix this issue

samtstern commented 6 years ago

This issue has been fixed and released in version 1.1.2

LolWalid commented 5 years ago

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.