PermissionsDispatcher 0,8,20,3,6,0,23,10 travis-ci

Simple annotation-based API to handle runtime permissions.


Build Status


  • 100% reflection-free
  • Special Permissions support
  • Xiaomi support

PermissionsDispatcher provides a simple annotation-based API to handle runtime permissions in Android Marshmallow.

This library lifts the burden that comes with writing a bunch of check statements whether a permission has been granted or not from you, in order to keep your code clean and safe.


Here’s a minimum example, in which we register a MainActivity which requires Manifest.permission.CAMERA.

0. Prepare AndroidManifest

Add the following line to AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />

1. Attach annotations

PermissionsDispatcher introduces only a few annotations, keeping its general API concise:

NOTE: Annotated methods must not be private.

Annotation Required Description
@RuntimePermissions Register an Activity or Fragment(we support both) to handle permissions
@NeedsPermission Annotate a method which performs the action that requires one or more permissions
@OnShowRationale Annotate a method which explains why the permission/s is/are needed. It passes in a PermissionRequest object which can be used to continue or abort the current permission request upon user input
@OnPermissionDenied Annotate a method which is invoked if the user doesn’t grant the permissions
@OnNeverAskAgain Annotate a method which is invoked if the user chose to have the device “never ask again” about a permission
public class MainActivity extends AppCompatActivity {

    void showCamera() {
                .replace(, CameraPreviewFragment.newInstance())

    void showRationaleForCamera(final PermissionRequest request) {
        new AlertDialog.Builder(this)
            .setPositiveButton(R.string.button_allow, (dialog, button) -> request.proceed())
            .setNegativeButton(R.string.button_deny, (dialog, button) -> request.cancel())

    void showDeniedForCamera() {
        Toast.makeText(this, R.string.permission_camera_denied, Toast.LENGTH_SHORT).show();

    void showNeverAskForCamera() {
        Toast.makeText(this, R.string.permission_camera_neverask, Toast.LENGTH_SHORT).show();

2. Delegate to generated class

Upon compilation, PermissionsDispatcher generates a class for MainActivityPermissionsDispatcher([Activity Name] + PermissionsDispatcher), which you can use to safely access these permission-protected methods.

The only step you have to do is delegating the work to this helper class:

protected void onCreate(Bundle savedInstanceState) {
    findViewById( -> {
      // NOTE: delegate the permission handling to generated method

public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    // NOTE: delegate the permission handling to generated method
    MainActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);

Check out the sample and generated class for more details.

Getting Special Permissions




Since Xiaomi manipulates something around runtime permission mechanism Google’s recommended way doesn’t work well. But don’t worry, PermissionsDispatcher supports it! Check related PR for more detail.

For AndroidAnnotations users

If you use AndroidAnnotations, you need to add AndroidAnnotationsPermissionsDispatcherPlugin to your dependencies so PermissionsDispatcher’s looks for AA’s subclasses (your project won’t compile otherwise).

Knows issues

See doc.


We’ve got hundreds of users around the world!


To add it to your project, include the following in your app module build.gradle file:

${latest.version} is Download

dependencies {
  compile('com.github.hotchemi:permissionsdispatcher:${latest.version}') {
      // if you don't use you can exclude support for them
      exclude module: "support-v13"
  annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:${latest.version}'

Snapshots of the development version are available in JFrog’s snapshots repository. Add the repo below to download SNAPSHOT releases.

repositories {
  maven { url '' }

For Jitpack users

If you include dependencies in your project, it is important to review the order of the repositories available to your app module. Because of the library’s artifact ID, Jitpack might be tempted to resolve the dependency on its own, which could lead to an error during Gradle’s configuration time:

Error: Module depends on one or more Android Libraries but is a jar

In short, please ensure that the jcenter() repository is located above Jitpack’s repository in your repositories block!


Copyright 2016 Shintaro Katafuchi, Marcel Schnelle, Yoshinori Isogai

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Related Repositories



Simple annotation-based API to handle runtime permissions. ...



IntelliJ plugin for supporting PermissionsDispatcher ...



Plugin for AndroidAnnotations allowing to use it together with PermissionsDispatcher ...

Top Contributors

hotchemi aurae shiraji sibelius esmasui egor-n jmatsu LouisCAD marciogranzotto intrications


-   2.2.0 zip tar
-   2.1.3 zip tar
-   2.1.2 zip tar
-   2.1.1 zip tar
-   2.1.0 zip tar
-   2.0.9 zip tar
-   2.0.8 zip tar
-   2.0.7 zip tar
-   2.0.6 zip tar
-   2.0.5 zip tar
-   2.0.4 zip tar
-   2.0.3 zip tar
-   2.0.2 zip tar
-   2.0.1 zip tar
-   2.0.0 zip tar
-   1.2.1 zip tar
-   1.2.0 zip tar
-   1.1.2 zip tar
-   1.1.1 zip tar
-   1.1.0 zip tar
-   1.0.1 zip tar
-   1.0.0 zip tar
-   0.9.0 zip tar
-   0.5.0 zip tar