permissions-dispatcher / PermissionsDispatcher

A declarative API to handle Android runtime permissions.
https://github.com/permissions-dispatcher/PermissionsDispatcher
Apache License 2.0
11.22k stars 1.44k forks source link

Explicitly check permissions #422

Closed d3bt3ch closed 6 years ago

d3bt3ch commented 6 years ago

How can I explicitly check permissions without using annotations using PermissionsDispatcher ?

mannodermaus commented 6 years ago

Relying on code generation and the annotation processor is arguably the cornerstone of PermissionsDispatcher's entire existence, so you won't gain much over the vanilla Android approach for Runtime Permissions if you don't use annotations.

If you still absolutely have to know the state of a given permission imperatively, our generated code uses boolean PermissionUtils.hasSelfPermissions(Context, String…) to check if permissions are granted.

d3bt3ch commented 6 years ago

I would completely agree with you and as you said sometimes you have to know the state of a given permission imperatively and was just wondering if there is any way to do that PermissionsDispatcher so as to avoid writing a helper class.

mannodermaus commented 6 years ago

Got it. You can use our PermissionUtils in that case, as mentioned above. We do reserve the right to introduce backwards-incompatible changes to its API in later versions, but the signatures should remain pretty stable at this point, I suppose.