How to record voice call using AudioSource.VOICE_CALL

好久不见. 提交于 2019-12-05 13:26:25
Sudarshana Dayananda

VOICE_CALL is deprecated now. That is why this error occurred.

Use VOICE_COMMUNICATION as AudioSource as it is microphone audio source tuned for voice communications such as VoIP.

I am also working with call recording app but it failed in Android 7.1.1

If you are not trying call record on Android 7.1.1 below code will work.

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

In order to use VOICE_CALL you need to take special permission.

 <uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT"
   tools:ignore="ProtectedPermissions" />

I think you require some permissions before recording in newer version of android (Api 23). Check out this SO question - Recording calls in android why this not works

Permissions

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>

And if you require more help you can even check official document for more info regarding this error.

You need the CAPTURE_AUDIO_OUTPUT permission for Voice_Call, which is documented here.

But you will NOT get the permission for the reason stated here.

Note the line "Not for use by third-party applications."

I think you forgot to take this permission.

    <uses-permission android:name="android.permission.CALL_PHONE" />
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!