Permission requests outside Activity
viniciusdepaula opened this issue · comments
How can i make permission requests outside of the context of an Activity?
Hi there! As long as your activity either extends PermisoActivity
or does the steps detailed in the README, then the Permiso
class has already been seeded with the current activity, and you can make calls against it from anywhere. e.g. Permiso.getInstance().requestPermissions(...)
.
Note that "outside the context of an Activity" means that you still have some foreground UI (meaning an activity is still running), but you want to request the permission in some non-Activity non-Fragment class (like a class you've written to manage writes to storage, contacts, etc - this was the primary use case that caused me to write Permiso).
If you need to request a permission in a background service, you'll first have to start an Activity before you can make the request. In instances like this, I recommend getting the permission during a first-time user flow when you have some UI showing.