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

前端 未结 5 1533
青春惊慌失措
青春惊慌失措 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);
    }
    

提交回复
热议问题