moko-permissions icon indicating copy to clipboard operation
moko-permissions copied to clipboard

Avoid requiring binding when checking permission state

Open hrodrick opened this issue 1 month ago • 0 comments

Hi, I am verifying if a user has permissions on background via an android service at startup, and I am receiving an exception that crashes the app because the app's activity is null (which is true). The problem is that the activity is expected to be null, because I am verifying permissions in background. My use case is to avoid collecting background location data if the user never gave permission.

I check permissions with this:

permissionsController.let {
    it.getPermissionState(Permission.LOCATION) != PermissionState.Granted
            || it.getPermissionState(Permission.BACKGROUND_LOCATION) != PermissionState.Granted
}

As far as i know, there shouldn´t be any need to bind the controller with an activity if we are just checking if permissions are granted (so, not prompting)

is this a bug, or am I missing something?

Thanks!

hrodrick avatar Dec 01 '25 12:12 hrodrick