explaingit

permissions-dispatcher/permissionsdispatcher

11,179JavaAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Android library that cuts out the repetitive code required to ask users for permissions by letting you declare all the handling logic with simple annotations on your methods.

Mindmap

mindmap
  root((permissionsdispatcher))
    What it does
      Removes boilerplate
      Annotation-driven
      Compile-time codegen
    Key Annotations
      NeedsPermission
      OnPermissionDenied
      OnShowRationale
    Tech Stack
      Java and Kotlin
      Android Jetpack
      Annotation processor
    Use Cases
      Camera access
      Location requests
      Microphone permission
    Audience
      Android developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace messy permission-handling if-else blocks in your Android app with clean method annotations.

USE CASE 2

Handle camera, microphone, or location permissions in a Kotlin app by adding three annotations instead of writing boilerplate callbacks.

USE CASE 3

Show a rationale dialog before the system permission prompt appears, using the @OnShowRationale annotation.

Tech stack

JavaKotlinAndroidJetpackAnnotation Processor

Getting it running

Difficulty · easy Time to first run · 30min

Requires Jetpack (AndroidX) support libraries, older android.support library versions are not compatible with version 4.x and later.

Use freely for any purpose including commercial, as long as you keep the copyright and license notice (Apache 2.0).

In plain English

PermissionsDispatcher is a library for Android app developers that reduces the amount of repetitive code needed to ask users for permissions. Android apps need to request certain permissions at runtime before accessing things like the camera, microphone, or location. Without a helper library, handling all the possible outcomes (user grants, user denies, user checks "never ask again") requires a lot of manual checks scattered throughout the code. This library uses annotations, which are small tags you add to your methods, to declare how each permission scenario should be handled. You mark a method with @NeedsPermission to say it requires a particular permission, add @OnPermissionDenied to specify what happens if the user refuses, and optionally add @OnShowRationale to provide an explanation before the system dialog appears. The library then generates the necessary boilerplate code automatically at build time. Because the code is generated at compile time rather than looked up at runtime, the library does not use reflection, which keeps it fast and avoids potential compatibility issues on certain Android versions. The library works with both Kotlin and Java. Kotlin users can also use a separate ktx extension that offers a more idiomatic API. Installation involves adding two lines to the app build configuration file: one for the library itself and one for the annotation processor that generates the boilerplate. It requires the Jetpack version of Android support libraries (version 4.x and later). The code is released under the Apache License 2.0.

Copy-paste prompts

Prompt 1
I'm building an Android app in Kotlin that needs camera permission. Show me how to add PermissionsDispatcher with the @NeedsPermission, @OnPermissionDenied, and @OnShowRationale annotations.
Prompt 2
Add PermissionsDispatcher to my Android project, show me the two lines I need in my build.gradle file and a working example of requesting location permission.
Prompt 3
My Android app needs to handle the 'never ask again' case for microphone permission, how do I set that up with PermissionsDispatcher's annotations?
Prompt 4
Convert this verbose Android permission-handling code to use PermissionsDispatcher annotations: [paste your code here]
Open on GitHub → Explain another repo

← permissions-dispatcher on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.