Here is my class that handle all MarshMallow Permissions I prefer separate it class as I will call its methods in all my apps.At  first I get used to check permission by this way:private void CheckPermissionGranted() {   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CHECK_PERMISSION_CODE);            return;        }    }}and here is my class to handle all permissions: import android.Manifest;import android.app.Activity;import android.content.pm.PackageManager;import android.support.v4.app.ActivityCompat;import android.support.v4.content.ContextCompat;import android.widget.Toast;/** * Created by mina on 10/9/2016. */public class MarshMallowPermission {    public static final int RECORD_PERMISSION_REQUEST_CODE = 1;    public static final int WRITE_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE = 2;    public static final int READ_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE = 3;    public static final int CAMERA_PERMISSION_REQUEST_CODE = 4;    Activity activity;    public MarshMallowPermission(Activity activity) {        this.activity = activity;    }    public boolean checkPermissionForRecord(){        int result = ContextCompat.checkSelfPermission(activity, Manifest.permission.RECORD_AUDIO);        if (result == PackageManager.PERMISSION_GRANTED){            return true;        } else {            return false;        }    }    public boolean checkPermissionForWriteExternalStorage(){        int result = ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);        if (result == PackageManager.PERMISSION_GRANTED){            return true;        } else {            return false;        }    }    public boolean checkPermissionForReadExternalStorage(){        int result = ContextCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE);        if (result == PackageManager.PERMISSION_GRANTED){            return true;        } else {            return false;        }    }    public boolean checkPermissionForCamera(){        int result = ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA);        if (result == PackageManager.PERMISSION_GRANTED){            return true;        } else {            return false;        }    }    public void requestPermissionForRecord(){        if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.RECORD_AUDIO)){            Toast.makeText(activity, Microphone permission needed for recording. Please allow in App Settings for additional functionality., Toast.LENGTH_LONG).show();        } else {            ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.RECORD_AUDIO},RECORD_PERMISSION_REQUEST_CODE);        }    }    public void requestPermissionForWriteExternalStorage(){        if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)){            Toast.makeText(activity, External Storage permission needed. Please allow in App Settings for additional functionality., Toast.LENGTH_LONG).show();        } else {            ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},WRITE_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE);        }    }    public void requestPermissionForReadExternalStorage(){        if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.READ_EXTERNAL_STORAGE)){            Toast.makeText(activity, External Storage permission needed. Please allow in App Settings for additional functionality., Toast.LENGTH_LONG).show();        } else {            ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},READ_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE);        }    }    public void requestPermissionForCamera(){        if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.CAMERA)){            Toast.makeText(activity, Camera permission needed. Please allow in App Settings for additional functionality., Toast.LENGTH_LONG).show();        } else {            ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.CAMERA},CAMERA_PERMISSION_REQUEST_CODE);        }    }}I check permission when use click button to upload Image from Camera or image library private void selectImage() {    final CharSequence[] items = {str_camera, str_image_lib,            str_cancel};    AlertDialog.Builder builder = new AlertDialog.Builder(UploadActivity.this);    builder.setTitle(Add Files!);    builder.setItems(items, new DialogInterface.OnClickListener() {        @Override        public void onClick(DialogInterface dialog, int item) {            if (items[item].equals(str_camera)) {                if (!marshMallowPermission.checkPermissionForCamera()) {                    marshMallowPermission.requestPermissionForCamera();                    return;                }                dispatchTakePictureIntent();            } else if (items[item].equals(str_image_lib)) {                if (!marshMallowPermission.checkPermissionForReadExternalStorage()) {                    marshMallowPermission.requestPermissionForReadExternalStorage();                    return;                }                enableBrowseFile();            } else if (items[item].equals(str_cancel)) {                dialog.dismiss();            }        }    });    builder.show();}if permission not granted I request permission , if granted I call methods that required this permission to run@Overridepublic void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {    switch (requestCode) {        case MarshMallowPermission.READ_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE:            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {                enableBrowseFile();            } else {                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {                    marshMallowPermission.requestPermissionForReadExternalStorage();                }            }            break;        case MarshMallowPermission.CAMERA_PERMISSION_REQUEST_CODE:            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {                dispatchTakePictureIntent();            } else {                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {                    marshMallowPermission.requestPermissionForCamera();                }            }            break;    }}
Android class to handle MarshMallowPermission
java;android;authorization