Voice Call Recording on Android Lollipop and higher version not working
Asked Answered
C

1

6

I'm getting problem in recording voice call in android lollipop and higher version. By this code I'm able to record my voice, but not able to record other person voice.

    public void startRecording() {
    if (recording == false) {


        Log.e("here", "--------Recorder_Sarted------" + fname);
        SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy");
        int randomPIN = (int) (Math.random() * 9000) + 1000;
        recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        String file = Environment.getExternalStorageDirectory().toString();
        String filepath = file + "/Aeris/Recording";
        File dir = new File(filepath);
        dir.mkdirs();
        Log.e("here ", "----------------" + sdf.format(Calendar.getInstance().getTime()) + " " + fname + " " + type);
        filepath += "/" + type + "-" + fname + "-" + sdf.format(Calendar.getInstance().getTime()) + "-" + randomPIN + ".3gp";
        recorder.setOutputFile(filepath);

        try {
            recorder.prepare();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        recorder.start();
        recording = true;
    }
}

This code is working fine below android lollipop version. please help me to solve this problem

Cardiogram answered 13/1, 2016 at 8:47 Comment(0)
M
0

Chane the AudioSource VOICE_COMMUNICATION to MIC (Microphone)

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);

Tested in Moto g2(Android 6.0), lenovo (Android 5.0), its working fine.

Morel answered 1/4, 2016 at 10:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.