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

前端 未结 5 1502
青春惊慌失措
青春惊慌失措 2021-02-10 13:47

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 cor

相关标签:
5条回答
  • 2021-02-10 14:25

    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);
    }
    
    0 讨论(0)
  • 2021-02-10 14:30

    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.

    0 讨论(0)
  • 2021-02-10 14:35

    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);
    
    0 讨论(0)
  • 2021-02-10 14:38

    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
    
    0 讨论(0)
  • 2021-02-10 14:43

    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.

    0 讨论(0)
提交回复
热议问题