i am trying to record voice call on android. I am using AudioRecord class/api of android to perform this. But for some reason AudioRecord is not able to record voice call on some devices (especially with latest OS 6.0, 7.0). Whenever i set the AudioSource param of AudioRecord object to "VOICE_CALL" i.e (MediaRecorder.AudioSource.VOICE_CALL), it gives me this exception
java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord
But when i set the audiosource to "MIC", it works fine, but of course not records the voice call.
I've tried to use MediaRecord class of android but faced the same issue i.e works fine for "MIC" but lacks on "VOICE_CALL". I also tried many available solutions on multiple forums as well but still no luck.
Below i shared a little piece of my code. Any help on this will be much appreciated. Thanks
recorder = new AudioRecord(MediaRecorder.AudioSource.VOICE_CALL,
44100, AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT, AudioRecord.getMinBufferSize(44100,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT));
recorder.startRecording();