How can I record voice and record Call in Android?

PrashantAdesara picture PrashantAdesara · Nov 16, 2010 · Viewed 65.6k times · Source

Please help me if you know how can record outgoing and incoming call in android

Answer

Abhijit Chakra picture Abhijit Chakra · Aug 29, 2013

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();