安卓判断麦克风权限

public boolean isVoicePermission() {//判断麦克风权限
try {
AudioRecord record = new AudioRecord(MediaRecorder.AudioSource.MIC, 22050, AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT, AudioRecord.getMinBufferSize(22050, AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT));
record.startRecording();
int recordingState = record.getRecordingState();
if(recordingState == AudioRecord.RECORDSTATE_STOPPED){
return false;
}
record.release();
return true;
} catch (Exception e) {
return false;
}

}

转载于:https://www.cnblogs.com/cw828/p/10113548.html

你可能感兴趣的:(安卓判断麦克风权限)