android|android 6.0 常用权限请求

【android|android 6.0 常用权限请求】请求6.0以上手机的读写文件、相机权限,可根据需要自己添加

private static final int REQUEST_PERMISSIONS = 1000; private void requestPermissons(){ String[]permissions= new String[]{ Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,//文件读写 Manifest.permission.CAMERA,//相机 Manifest.permission.RECORD_AUDIO//音频 }; if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){ if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)){ Toast.makeText(this, "用户曾拒绝xxxx", Toast.LENGTH_SHORT).show(); }else { ActivityCompat.requestPermissions(this, permissions, REQUEST_PERMISSIONS); } } }

    推荐阅读