Android M 权限

检查权限

if (ContextCompat.checkSelfPermission(thisActivity,
                Manifest.permission.READ_CONTACTS)
        != PackageManager.PERMISSION_GRANTED) {
}else{
    //
}

权限已授权则返回PackageManager.PERMISSION_GRANTED,否则PERMISSION_DENIED

申请权限

ActivityCompat.requestPermissions(thisActivity,
                new String[]{Manifest.permission.READ_CONTACTS},
                MY_PERMISSIONS_REQUEST_READ_CONTACTS);

#

你可能感兴趣的:(Android M 权限)