Karumi / Dexter

Android library that simplifies the process of requesting permissions at runtime.
http://karumi.com
Apache License 2.0
5.23k stars 671 forks source link

Is this recreation safe? How? #224

Closed natario1 closed 4 years ago

natario1 commented 5 years ago

How does Dexter deal with activity recreation?

By this I mean, I ask for permissions, permission dialog is shown, then I close the app and go to another. Android might kill the app after saving its state. When going back the whole stack is recreated and dialog should still be shown. But I don't see how you would retain the PermissionListener object.

deinlandel commented 4 years ago

This problem doesn't seem to be in scope of the library. PermissionListener will usually hold some kind of reference to view or at least context, so it should be destroyed if your activity is destroyed. And library doesn't know how and when this listener was created so it's impossible for it to be recreated automatically. It's up to your application to remember the fact that permissions were requested and request them again.

Serchinastico commented 4 years ago

@deinlandel explained it perfectly!

natario1 commented 4 years ago

It's up to your application to remember the fact that permissions were requested and request them again.

In the normal flow of permissions (without any lib), it's not up to the application - it actually comes for free. Dialog will be re-shown automatically and the permission results listener will be called in the new activity/fragment. So this is a drawback of the library. Anyway, thanks for your answer!