android中通话录音

时间:2022-08-02 05:27:38

file = new File(Environment.getExternalStorageDirectory(),
this.incomeNumber + System.currentTimeMillis()
+ ".3gp");
System.out.println(">>>>>>接通>>>>>>>>" + state);
mediaRecorder = new MediaRecorder();
// mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
//获得声音数据源(下麦克风)
mediaRecorder
.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);//这个设置就是获取双向声音
mediaRecorder
.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); // 按3gp格式输出
mediaRecorder
.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setOutputFile(file.getAbsolutePath()); // 输出文件
mediaRecorder.prepare(); // 准备
mediaRecorder.start();