Is it possible in android to record a call during incoming or outgoing calls

In android, you can record voice calls during incoming / outgoing calls without opening the speaker of your mobile phone. I saw an application on the Android market. It doesn’t record another side voice without opening the speaker, because a microphone is used for recording. Can this be done using other methods?

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();
+4
source share
5 answers

Setting the sound source for MIC worked for me.

CallRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);

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

, , .

0

Android ( ) . , ( HW) . , .

, , HW.

-1

MediaRecorder.AudioSource.VOICE_DOWNLINK MediaRecorder.AudioSource.VOICE_UPLINK .

.

Callrecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK | MediaRecorder.AudioSource.VOICE_UPLINK);
-1

MediaRecorder :

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);
}
-1

You need to use the MediaRecorder class ,

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
-2
source

All Articles