Couldn't hear incoming voice in recorded calls in android 7?
Asked Answered
S

4

8

I am developing an Android app for recording calls. This is my code snippet.

    recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    recorder.setOutputFile(file_path);

This is working perfectly for devices below android 7, but when I use Android 7 mobile devices I can hear only outgoing voice but cannot hear incoming voice.

Can anyone help me in fixing it?

Shannon answered 22/11, 2017 at 13:7 Comment(0)
H
4

Use VOICE_COMMUNICATION as AudioSource as it is microphone audio source tuned for voice communications such as VoIP, as described on Android Developers site.

I tried using VOICE_CALL(Uses audio uplink and downlink recording) but it can be used only by system components only, So mic is only option to record audio.

TRY:
1: Sliding up the volume during call.
2. DO NOT use headphones as audio will not be recorded by mic in some cases[Haven't tried this]. 3. Works on Moto G4 Play, Android version 7.1.1(most of Motorola phones have two mics):

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION); recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

Heroin answered 28/11, 2017 at 11:46 Comment(1)
I think the problem lies with the phone you are using, as you are able to record outgoing voice. The mic placement on your phone is in such a way that it can't record incoming in normal mode. Did you tried using speakerphone?Heroin
P
3

Well, the problem is that you only record the microphone input with that code, which is obviously just the outgoing voice. To also record the incoming voice, you'd have to also record system sound.

To record system sound, you'll have to google a bit. Here are some stackoverflow links that should get you started:

In the end, you'd also have to merge the two soundtracks into one file to have the whole call as one.

Paillasse answered 22/11, 2017 at 13:30 Comment(1)
That must have a different reason, because the code you posted only records microphone input sound.Paillasse
W
2
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

try using this

Weinshienk answered 22/11, 2017 at 13:8 Comment(1)
Tried this in pixel 2 with Android P, the output file does not have any content.Helgoland
E
2

this code works like a charm for Android 7 built with API 25,

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
recorder.setAudioSamplingRate(8000);
recorder.setAudioEncodingBitRate(12200);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
Excavate answered 8/12, 2017 at 10:11 Comment(1)
Ends with exception "start failed." in pixel 2 with Android P.Helgoland

© 2022 - 2024 — McMap. All rights reserved.