Github url


by permissions-dispatcher

permissions-dispatcher /PermissionsDispatcher

A declarative and comprehensive API to handle Android runtime permissions.

10.1K Stars 1.3K Forks Last release: 4 months ago (4.7.0) Apache License 2.0 726 Commits 45 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

PermissionsDispatcher Build Status PermissionsDispatcher

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

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.


  • if you're not a huge fun of kapt, you can try ktx.
  • Java

Here's a minimum example, in which you register a


which requires



0. Prepare AndroidManifest

Add the following line to



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

1. Attach annotations

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

NOTE: Annotated methods must not be



|Annotation|Required|Description| |---|---|---| |


||Register an




to handle permissions| |


||Annotate a method which performs the action that requires one or more permissions| |


||Annotate a method which explains why the permissions are needed. It passes in a


object which can be used to continue or abort the current permission request upon user input. If you don't specify any argument for the method compiler will generate




. You can use those methods in place of


(ex: with


)| |


||Annotate a method which is invoked if the user doesn't grant the permissions| |


||Annotate a method which is invoked if the user chose to have the device "never ask again" about a permission|

@RuntimePermissions class MainActivity : AppCompatActivity(), View.OnClickListener { @NeedsPermission(Manifest.permission.CAMERA) fun showCamera() { supportFragmentManager.beginTransaction() .replace(\_content\_fragment, CameraPreviewFragment.newInstance()) .addToBackStack("camera") .commitAllowingStateLoss() } @OnShowRationale(Manifest.permission.CAMERA) fun showRationaleForCamera(request: PermissionRequest) { showRationaleDialog(R.string.permission\_camera\_rationale, request) } @OnPermissionDenied(Manifest.permission.CAMERA) fun onCameraDenied() { Toast.makeText(this, R.string.permission\_camera\_denied, Toast.LENGTH\_SHORT).show() } @OnNeverAskAgain(Manifest.permission.CAMERA) fun onCameraNeverAskAgain() { Toast.makeText(this, R.string.permission\_camera\_never\_askagain, Toast.LENGTH\_SHORT).show() } }

2. Delegate to generated functions

Now generated functions become much more concise and intuitive than Java version!

override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity\_main) findViewById(\_camera).setOnClickListener { // NOTE: delegate the permission handling to generated function showCameraWithPermissionCheck() } } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<string>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        // NOTE: delegate the permission handling to generated function
        onRequestPermissionsResult(requestCode, grantResults)

Check out the sample for more details.

Other features/plugins


NOTE: 4.x only supports Jetpack. If you still use appcompat 3.x is the way to go.

To add PermissionsDispatcher to your project, include the following in your app module




is Download

dependencies { implementation "org.permissionsdispatcher:permissionsdispatcher:${latest.version}" annotationProcessor "org.permissionsdispatcher:permissionsdispatcher-processor:${latest.version}" }

With Kotlin:

apply plugin: 'kotlin-kapt' dependencies { implementation "org.permissionsdispatcher:permissionsdispatcher:${latest.version}" kapt "org.permissionsdispatcher:permissionsdispatcher-processor:${latest.version}" }

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



repositories { jcenter() maven { url '' } }


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, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.