11
VOICE_CALL, VOICE_DOWNLINK ,VOICE_UPLINK  

not working on android 4.0 but working on android 2.3 (Actual Device),I have uploaded a dummy project to record all outgoing call so that you can see it for your self

http://www.mediafire.com/?img6dg5y9ri5c7rrtcajwc5ycgpo2nf

you just have to change audioSource = MediaRecorder.AudioSource.MIC; to audioSource = MediaRecorder.AudioSource.VOICE_CALL; on line 118 in TService.java

If you come across any error, tell me. Any suggestion related to it will be accepted.

CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
Auto-Droid ツ
  • 1,583
  • 1
  • 17
  • 31

4 Answers4

16

After a lot of search I Found that Some Manufactures have closed the access to such function because call recording is not allowed in some countries. If anyone finds such question and get the solution some other way then post it over here it may be helpful to many because many people are have the same issue.

Auto-Droid ツ
  • 1,583
  • 1
  • 17
  • 31
  • thanks a lot. your solution works perfect. I run the project in samsung galaxy s2. I am able to record both the caller and other party's voice. However, the voice of the other party is very low, any particular reason for this problem? – suresh cheemalamudi Mar 29 '13 at 12:39
  • the recording is done using mic so the opponents voice is low you just have to change audioSource = MediaRecorder.AudioSource.MIC; to audioSource = MediaRecorder.AudioSource.VOICE_CALL; on line 118 in TService.java – Auto-Droid ツ Mar 30 '13 at 06:53
  • voice call doesn't work in some device so it may throw and exception as stop() failed or start failed -21 – Auto-Droid ツ Mar 30 '13 at 06:55
  • yeah, you are right, when i changed audioSource = MediaRecorder.AudioSource.VOICE_CALL, i am getting an exception as soon as i make a phone call. how to solve this problem? – suresh cheemalamudi Mar 30 '13 at 07:10
  • 2
    Bro it has been a month I am looking for the solution so I posted this question on Stack but no one answered – Auto-Droid ツ Mar 30 '13 at 11:24
  • 4
    Remember it will give exception only on that device in which voice call is not supported so catch the exception and start the recording from mic all over again that will keep you on safer side in non supported device . – Auto-Droid ツ Mar 30 '13 at 11:27
  • but how to record outgoing call ? how to detect outgoing call has been recieved and will start recording ? – Android Killer May 20 '13 at 07:58
  • When I used MediaRecorder.AudioSource.VOICE_CALL , It give me null pointer exception and Uplink and downlink the voice is not audible after record but in the caase of mic work fine as you said. So, there is any solution for this uplink and downlink ? – Akarsh M Nov 23 '13 at 06:31
  • Unless you root your phone VOICE_CALL, Uplink and downlink will not be available incase of some device ,as per my above answer Manufactures have closed the access to such function ,mic is the only source which will be avaliable for recording – Auto-Droid ツ Nov 23 '13 at 06:48
  • in play store so many apps which allows recording calls. how those apps works well? – Aditya Vyas-Lakhan Apr 05 '17 at 06:03
  • Hi @AdityaVyas-Lakhan, I have also uploaded my app on play store and that works as well and has thousands of active downloads – Auto-Droid ツ Apr 05 '17 at 06:25
  • in all device it works well? can you give that app link? – Aditya Vyas-Lakhan Apr 05 '17 at 06:48
  • I made it 4 yrs back and I'm not maintaining it https://play.google.com/store/apps/details?id=com.rivalogic.android.callrecorder – Auto-Droid ツ Apr 05 '17 at 08:52
  • I am using Samsung Galaxy S8+ and it is not able to record voice using `VOICE_CALL`, `VOICE_UPLINK`, `VOICE_DOWNLINK` except `VOICE_MIC` and `VOICE_RECOGNITION`. But if I download apps from the play store then they are able to work in my phone. So, I don't think manufacturer is someone who comes into play here. – CopsOnRoad Mar 09 '18 at 14:15
  • @CopsOnRoad test the same code with other devices to make sure its working properly, If other apps are working then your code should work as well. – Auto-Droid ツ Mar 11 '18 at 06:05
  • @Auto-Droidツ I tried using NDK and it is now working fine in my S8+ but the problem is of voice quality. It is very irregular and non uniform. If you can help me then we can have a deal. – CopsOnRoad Mar 11 '18 at 07:02
1

Try to use MediaRecorder.AudioSource.VOICE_RECOGNITION. I had the same problem - ASUS Transformer uses microphone near the back camera by default and audio is very silent in this case. VOICE_CALL doesn't work on this tablet and I have tried VOICE_RECOGNITION - in that case it uses front microphone and audio volume is OK.

1

OK, in my case this code (thank you eyal!) worked for Samsung Galaxy Note 6:

String manufacturer = Build.MANUFACTURER;
if (manufacturer.toLowerCase().contains("samsung")) {
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
} else {
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
}
Jalal
  • 6,594
  • 9
  • 63
  • 100
-2

you try to add this,it may be

new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
        // TODO Auto-generated method stub
        mMediaRecorder.start();
    }
}, 1000);
Tunaki
  • 132,869
  • 46
  • 340
  • 423