4

In android is it possible to record voice call during incoming/outgoing calls without open the speaker of mobile. I had seen a application in the android market. It does not correctly record other side voice without opening the speaker because it uses mic for recording purpose. May it be done by some other techniques?

final MediaRecorder callrecorder = new MediaRecorder();

callrecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
callrecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
callrecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
callrecorder.setOutputFile(recordPath);
callrecorder.prepare();
callrecorder.start();
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
shyam
  • 1,276
  • 4
  • 25
  • 51
  • 2
    although it is possible to record, but in some countries it is illegal, long ago we have made a Blackberry App but that was banned due to violation of some privacy law. – Yuvi Feb 07 '12 at 06:46
  • Yes it is possible, Please check [this](http://stackoverflow.com/questions/6839297/record-call-in-android-2-2) link. You can also find sample code for recording. – Lucifer Feb 07 '12 at 06:38
  • is it possible without opening the speaker of mobile? – shyam Feb 07 '12 at 06:41

5 Answers5

0

Setting the audio source to MIC worked for me..

CallRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);

But not all devices provide the hardware support for call recording. Refer this [link]: http://forum.xda-developers.com/showthread.php?t=926498.

The outcome was that in some phones both the caller and callee's voice got recorded whereas in others only the speaker's voice was recorded.

user936414
  • 7,574
  • 3
  • 30
  • 29
-1

You can check with both audio source MediaRecorder.AudioSource.VOICE_DOWNLINK & MediaRecorder.AudioSource.VOICE_UPLINK at time.

This solution worked for me.

Callrecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK | MediaRecorder.AudioSource.VOICE_UPLINK);
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
-1

You can use MediaRecorder class as follows:

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    Log.d(TAGS, "In M" + "In M");
    Toast.makeText(this, "6.0", Toast.LENGTH_SHORT).show();
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
} else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
    Log.d(TAGS, "NNNN" + "NNNN");
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
} else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
    Log.d(TAGS, "N_MR1" + "N_MR1");
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
} else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    Log.d(TAGS, "O" + "O");
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
} else {
    Log.d(TAGS, "ELSE" + "ELSE ");
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
}
ℛɑƒæĿᴿᴹᴿ
  • 4,983
  • 4
  • 38
  • 58
-1

Android phones (to my knowledge) have an application processor and a modem processor. When the phone is in a voice call, audio data is routed (unless there is a HW change) from the modem processor to the audio hardware directly. The application processor is blissfully unaware of the audio data, but only knows of the call status.

So, in short you will not be able to record the audio data without the appropriate HW support.

santosh
  • 112
  • 4
  • which type of hardware support required which android don't have in all version..is there limitations for android versions also? – shyam Feb 07 '12 at 07:22
  • It has nothing to do with the version of Android. HW support implies PCM lines to be drawn from the modem processor to the application processor. – santosh Feb 07 '12 at 07:28
  • you may try an app called *Cube ACR* which can clearly record conversation in a call. – Z fp Oct 13 '18 at 11:54
-2

You need use MediaRecorder class as follows,

recorder = new MediaRecorder();
int audioSource = MediaRecorder.AudioSource.VOICE_CALL;
recorder.setAudioSource(audioSource);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
final String filePath = Environment.getExternalStorageDirectory() + "/record.3gpp";
final File file = new File(filePath);
file.getParentFile().mkdirs();
recorder.setOutputFile(filePath);
recorder.prepare();
recorder.start(); // Recording is now started
Lucifer
  • 29,392
  • 25
  • 90
  • 143