/DexterPermissionChecker

Dexter is an Android library that simplifies the process of requesting permissions at runtime.

Primary LanguageJava

DexterPermissionChecker

Dexter is an Android library that simplifies the process of requesting permissions at runtime.

Sample Code:

/**
 * Requesting camera permission
 * This uses single permission model from dexter
 * Once the permission granted, opens the camera
 * On permanent denial opens settings dialog
 */
private void requestCameraPermission() {
    Dexter.withActivity(this)
            .withPermission(Manifest.permission.CAMERA)
            .withListener(new PermissionListener() {
                @Override
                public void onPermissionGranted(PermissionGrantedResponse response) {
                    // permission is granted
                    openCamera();
                }

                @Override
                public void onPermissionDenied(PermissionDeniedResponse response) {
                    // check for permanent denial of permission
                    if (response.isPermanentlyDenied()) {
                        showSettingsDialog();
                    }
                }

                @Override
                public void onPermissionRationaleShouldBeShown(PermissionRequest permission, PermissionToken token) {
                    token.continuePermissionRequest();
                }
            }).check();
}

Screen 1:

Screen 2:

Screen 3:

Screen 4: