41

I am trying to understand is there a way I can record calls incoming and outgoing on android phones 2.2 and above?

A client wants to record calls of the agents they make to the clients so that it can be later used to fill out some material. Instead of making the client wait while on call they want to do it later on.

Is this possible and what APIs do I need to use?

Swati Garg
  • 995
  • 1
  • 10
  • 21
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
  • HI all i faced same issue( Not getting other side voice ) with Samsung S7 and S8 other wise my prog is run very well on rest of phones Any idea about ?? https://stackoverflow.com/questions/45880954/media-recorder-to-record-calls-is-sometime-unable-to-record-other-side-voice – Bhanu Sharma Aug 30 '17 at 13:10

4 Answers4

34

First off, you have to be careful with recording calls as there are legal requirements depending on the country.

Here is a blog post on how to record audio using the MediaRecorder.

I haven't tried recording phone call's but there is a option in MediaRecorder AudioSource for:

  • VOICE_CALL - Voice call uplink + downlink audio source
  • VOICE_DOWNLINK - Voice call downlink (Rx) audio source
  • VOICE_UPLINK - Voice call uplink (Tx) audio source

As long as the audio source options work, you should be good to go.

Ben McCann
  • 18,548
  • 25
  • 83
  • 101
Shane Powell
  • 13,698
  • 2
  • 49
  • 61
  • VOICE_CALL - Voice call uplink + downlink audio source VOICE_DOWNLINK - Voice call downlink (Rx) audio source VOICE_UPLINK - Voice call uplink (Tx) audio source are not working in android 4.0 do you have any idea on it – Auto-Droid ツ Feb 06 '13 at 08:03
  • HI all i faced same issue( Not getting other side voice ) with Samsung S7 and S8 other wise my prog is run very well on rest of phones Any idea about ?? – Bhanu Sharma Aug 30 '17 at 13:09
  • Successfully record the caller voice only using "blog post" link. But unable to record receiver end voice... Why ? – Imran Khan Saifi Sep 11 '17 at 11:58
  • 1
    To make it more clear. These AudioSources need CAPTURE_AUDIO_OUTPUT permission. Which is only granted to system applications. Second thing AudioSource.VOICE_COMMUNICATION doesn't need that permission and works well on pre 7.0 devices. But that doesn't record other side's voice on devices running 7.0 and above. – Bhupesh Mar 06 '18 at 05:11
  • Seems only system apps can use the VOICE_CALL, UPLINK and DOWNLINK. I was tried lot of call recorder coding in my Lenovo Zuk Z2 plus mobile with several audio sources but none of them are worked in recording the receiver voice. Cube ACR and Automatic call recorder apps are working perfectly in my mobile. Anyone please let me know how they can achive it? – Jayavinoth Feb 23 '19 at 18:44
3

I am using mic to record calls for better support and compatibility.

MediaRecorder recorder = new MediaRecorder();
recorder.reset();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setOutputFile(your_desired_folder_path);
 try {
    recorder.prepare();
} catch (java.io.IOException e) {
    recorder = null;
    return;
}
recorder.start();
frogatto
  • 28,539
  • 11
  • 83
  • 129
Bilal Shahid
  • 490
  • 9
  • 16
1

I am using mic to record phone audio and also use the Telephony manager to find the calling state.

private MediaRecorder recorder;

  recorder = new MediaRecorder();
        try {
            recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            recorder.setAudioSamplingRate(44100);
            recorder.setOutputFile(your_desired_files_absoulte_path);
} catch (Exception e) {
e.printstacktrace ;
}

after that, you can easily start recording anywhere you want

recorder.prepare();
recorder.start();

and after finishing recording you can easily also stop the recording

recorder.stop();
recorder.reset();
recorder.release();
-16

to record just hit the menu button while in call in android phone it will store conversation in amr format and in root directory of sd card max 20min conversation.

jabir jazz
  • 187
  • 1
  • 2
  • 10