Karumi / Dexter

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

Dev use context #148

Closed bastienpaulfr closed 7 years ago

bastienpaulfr commented 7 years ago

Hello,

In the last commit I have made some progress to use a Context instead of Activity. I had the need to use Dexter from a lib that has no activity and also from an Application class. It is working in these two uses cases.

I have also added the activity used for asking permission request in PermissionToken object. User can use this context to display a dialog when onPermissionRationaleShouldBeShown() is called.

I hope I have done things right for you to accept my push request.

BR

pedrovgs commented 7 years ago

@BasThomas if I'm not wrong, Dexter starts a transparent activity using the context provided as a param. That's why we need to request the Activity context and not any Context. If we configure the library to use any Context and the user decides to use the Application context, the library is going to crash due to the lack of a flag when the activity is launched.

We are going to wait for @Serchinastico review but if I'm not wrong, we can't just change the param. We should also provide another example using a different Context before merging this PR.

BasThomas commented 7 years ago

I think you meant to mention @bastienpaulfr here 😉