简体   繁体   English

Android 记录呼入和呼出

[英]Android Recording Incoming and Outgoing Calls

I am trying to understand is there a way I can record calls incoming and outgoing on android phones 2.2 and above?我想了解有没有办法可以在 android 手机 2.2 及更高版本上记录来电和去电?

A client wants to record calls of the agents they make to the clients so that it can be later used to fill out some material.客户想要记录他们对客户的代理呼叫,以便以后可以用来填写一些材料。 Instead of making the client wait while on call they want to do it later on.他们不想让客户在通话时等待,而是希望稍后再做。

Is this possible and what APIs do I need to use?这可能吗?我需要使用哪些 API?

First off, you have to be careful with recording calls as there are legal requirements depending on the country.首先,您必须小心录音,因为根据国家/地区的不同有法律要求。

Here is ablog post on how to record audio using the MediaRecorder .这是一篇关于如何使用MediaRecorder录制音频的博客文章。

I haven't tried recording phone call's but there is a option in MediaRecorder AudioSource for:我没有尝试录制电话,但MediaRecorder AudioSource中有一个选项用于:

  • VOICE_CALL - Voice call uplink + downlink audio source VOICE_CALL - 语音呼叫上行 + 下行音频源
  • VOICE_DOWNLINK - Voice call downlink (Rx) audio source VOICE_DOWNLINK - 语音呼叫下行链路 (Rx) 音频源
  • VOICE_UPLINK - Voice call uplink (Tx) audio source VOICE_UPLINK - 语音呼叫上行链路 (Tx) 音频源

As long as the audio source options work, you should be good to go.只要音频源选项有效,您应该对 go 很好。

I am using mic to record calls for better support and compatibility.我正在使用麦克风录制通话以获得更好的支持和兼容性。

MediaRecorder recorder = new MediaRecorder();
recorder.reset();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setOutputFile(your_desired_folder_path);
 try {
    recorder.prepare();
} catch (java.io.IOException e) {
    recorder = null;
    return;
}
recorder.start();

I am using mic to record phone audio and also use the Telephony manager to find the calling state.我正在使用麦克风录制电话音频,还使用电话管理器查找呼叫 state。

private MediaRecorder recorder;

  recorder = new MediaRecorder();
        try {
            recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            recorder.setAudioSamplingRate(44100);
            recorder.setOutputFile(your_desired_files_absoulte_path);
} catch (Exception e) {
e.printstacktrace ;
}

after that, you can easily start recording anywhere you want之后,您可以轻松地在任何您想要的地方开始录制

recorder.prepare();
recorder.start();

and after finishing recording you can easily also stop the recording完成录制后,您也可以轻松停止录制

recorder.stop();
recorder.reset();
recorder.release();

Call recording programmatically is erratic on android version 4 and is established to be only one side (even if possible) for security reasons.在 android 版本 4 上,以编程方式进行的通话录音不稳定,并且出于安全原因仅设置为一侧(即使可能)。 Many vendors have their own hardware implementations for call recording.许多供应商都有自己的用于通话录音的硬件实现。 There was a case in my app where I had to record a conference call by pressing hold and add a new call.在我的应用程序中有一个案例,我必须通过按住并添加新呼叫来记录电话会议。 The moment I pressed hold call recording stopped becuase the incall mode was gone.我按下保持通话录音的那一刻停止了,因为通话模式消失了。

to record just hit the menu button while in call in android phone it will store conversation in amr format and in root directory of sd card max 20min conversation.在 android 电话中通话时,只需点击菜单按钮即可录制,它将以 amr 格式存储对话,并在 sd 卡的根目录中存储最多 20 分钟的对话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM