Android Call Recording Incoming voice not getting recorded

后端 未结 6 835
猫巷女王i
猫巷女王i 2020-12-07 19:09

I\'m working auto call recorder app, I\'m able to record voice call on below android 6 using MediaRecorder.AudioSource.VOICE_CALL, From android 6 not able to r

6条回答
  •  死守一世寂寞
    2020-12-07 19:55

    First these 3 permissions are needed in Manifest as well as a runtime permission request if the device is above Marshmallow,

    
    
    
    
    1. MediaRecorder.AudioSource.VOICE_CALL is not supported on all phones so you need to continue using MediaRecorder.AudioSource.MIC.

    I use this and works fine on most of the devices,

          recorder = new MediaRecorder();
          recorder.setAudioSource(audioSource);
          recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
          recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
          recorder.setOutputFile(your_path);
    
    1. You need to set this to record your calls properly,

      audioManager.setMode(AudioManager.MODE_IN_CALL);

    raise volume level when you start recording

    audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL), 0);
    

    When you stop recording set the mode to normal, audioManager.setMode(AudioManager.MODE_NORMAL); and also set the stream volume to back how it was.

提交回复
热议问题