private void createAudioRecord() {
//上传的字节流需要限制在 4096以内,否则处理有问题, 采用 22050(缓存3584) ,32000(5120)
recBufSize = AudioRecord.getMinBufferSize(frequency,
channelConfiguration,
encodingBitRate); //最低 7680
audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
frequency,
channelConfiguration,
encodingBitRate,
recBufSize);
}
检测录音程序是否被禁用了,可以使用下面的代码判断
int read = audioRecord.read(data, 0, recBufSize);
if(AudioRecord.ERROR_INVALID_OPERATION != read){
// 做正常的录音处理
} else {
//录音可能被禁用了,做出适当的提示
}