动态申请权限

发布于 2018-06-03  9 次阅读


private static String[] PERMISSION_AUDIO = {
        android.Manifest.permission.RECORD_AUDIO,
        android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
        android.Manifest.permission.READ_EXTERNAL_STORAGE
};
int permission = android.support.v4.app.ActivityCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.RECORD_AUDIO);
if (permission != android.content.pm.PackageManager.PERMISSION_GRANTED) {
    android.support.v4.app.ActivityCompat.requestPermissions(MainActivity.this, PERMISSION_AUDIO, 1);
}