Please help me if you know how can record outgoing and incoming call in android
8 Answers
Yes It is possible just do this
final MediaRecorder callrecorder = new MediaRecorder();
callrecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
callrecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
callrecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
callrecorder.setOutputFile(filepath);
try {
callrecorder.prepare();
} catch (IllegalStateException e) {
System.out.println("An IllegalStateException has occured in prepare!");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
//throwing I/O Exception
System.out.println("An IOException has occured in prepare!");
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
callrecorder.start();
} catch(IllegalStateException e) {
e.printStackTrace();
//Here it is thorowing illegal State exception
System.out.println("An IllegalStateException has occured in start!");
}
for stopping you can use
callrecoder.stop();

- 446
- 7
- 15

- 3,201
- 37
- 66
-
I am getting "setAudioSource failed" exception on 2 devices: Galaxy S3 and Xperia Arc S. – Yar Jan 02 '15 at 08:43
-
upvoted for `MediaRecorder.AudioSource.VOICE_CALL` instead of `MediaRecorder.AudioSource.VOICE_COMMUNICATION` – Yogesh Seralia Dec 14 '16 at 10:16
-
1i am getting this error MediaRecorder: start failed: -2147483648 – Ajith K P Aug 01 '17 at 12:38
Check this out...
http://androidforums.com/android-lounge/181663-android-phone-call-recording-function.html
The short answer is... Get a Galaxy S, preferably the South Korean version.
As far as I know, all the applications that record voice calls on Android have the same problem: they only work on some phones, while on other phones you can only hear one side of the conversation. Some of these apps try to solve this problem by recording from the microphone as well.
If you have root permissions on your Android phone, then I believe there are apps that work better because they have access to the lower level streams, as Emmanuel specified in his answer.

- 18,309
- 4
- 30
- 35
-
What do the apps do with root exactly? How do they overcome this? – android developer Jun 21 '18 at 07:25
I dont know if its possible but as far as API goes
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
this line compiles well in my code where recorder is an Object of MediaRecorder and I was once working on such project but later the project was dumped so not sure if it works or not

- 15,249
- 7
- 52
- 81
You can't record a phone conversation on Android. The streams are in the lower level operating system and are not accessible in the application level. Sorry.

- 16,791
- 6
- 48
- 74
-
3How does apps like Automatic Call Recorder and others work? They work even without a root. – Zax Jan 29 '17 at 06:52
-
1
Depends on phone to phone e.g. You cannot record a call on nexus and motorola phones as they do not allow recording from mic till the call is on going. But the same recording from mic while on call works on most samsung and galaxy devices.

- 2,450
- 1
- 24
- 34
I am afraid of knowing android doesn't have a native api to record voice calls. even the streams are abstracted in Operating System and inaccessible in application layer as Emmanuel hase stated. I consider it as a Serious mistake of Android Devs. if a security Wall have one tiny Hole its not secure any more. So even if droid restricts or tries to restricts there exists other phones where one can have such kind of functionality. even a custom droid kernel can have such kind of functionality. This only makes droid Users poor nothing else.

- 12,638
- 12
- 82
- 146