I have a problem in recording a call I have made a service and called a BroadcastReceiver
to get the call state. In TelephonyManager.EXTRA_STATE_OFFHOOK
when the call is received. I am using following code to record the call
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
recorder.setOutputFile(audiofile.getAbsolutePath());
try {
recorder.prepare();
recorder.start();
}
catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception ex)
{
ex.printStackTrace();
}
This code is working fine and creates the audio file but when I listen the audio file I can only listen my outgoing voice, caller voice is not recorded.
When I use
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
instead of
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
in above code it throws exception of recoder fails on recoder.start();
So, how can I record voice call?