-1

I am creating an app for recording voice calls which is working fine on almost all devices. My problem is that the incoming voice is not recorded while making a call with earphones. I tried a number of ways to achieve this but failed to overcome this problem.

I tried with MediaRecorder and AudioRecord. As an example, here is my MediaRecorder sample:

MediaRecorder mediaRecorder = new MediaRecorder();                    
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setAudioSamplingRate(8000);

mediaRecorder.setAudioEncodingBitRate(12200);                    
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);                   
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);                    
mediaRecorder.setOutputFile(phoneCall.getPathToRecording());

mediaRecorder.prepare();
mediaRecorder.start();

Any suggestion is appreciated.

Srikanth M
  • 59
  • 1
  • 3

1 Answers1

0
Try to use below code.

MediaRecorder mediaRecorder = new MediaRecorder(); 
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION); 
mediaRecorder.setAudioSamplingRate(8000);
mediaRecorder.setAudioEncodingBitRate(12200); 
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB); 
mediaRecorder.setOutputFile(phoneCall.getPathToRecording());
mediaRecorder.prepare(); 
Thread.sleep(3000);
mediaRecorder.start();
yash786
  • 1,079
  • 6
  • 17