【问题标题】:Issue in call recording and not supporting in Android 7.0?通话录音有问题,Android 7.0 不支持?
【发布时间】:2017-11-13 22:12:29
【问题描述】:

问题是通话录音在 android 版本 6.0.1 之前工作正常,但在该 android 版本以上不能正常工作。

问题:-通话持续 1 分钟,但录音在 2 到 3 秒后停止。

此处编辑联系人文本:

edt_attempt_contact.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            final int DRAWABLE_RIGHT = 2;

            if (event.getAction() == MotionEvent.ACTION_UP) {
                if (event.getX() >= (edt_attempt_contact.getRight() - edt_attempt_contact.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                    if (!edt_attempt_contact.getText().toString().isEmpty()) {

                        Intent i = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + edt_attempt_contact.getText().toString()));
                        try {
                            startActivity(i);
                        }catch (SecurityException s){
                            s.printStackTrace();
                        }

                        try {
                            audioRecord();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    } else {
                        Toast.makeText(MainActivity.this, "Attempt Contact Number is required to call", Toast.LENGTH_SHORT).show();
                    }

                    return true;
                }
            }
            return false;
        }
    });
}

这是通话录音的主要代码。

 private void audioRecord() throws IOException {

    MediaRecorder recorder = new MediaRecorder();

    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    recorder.setOutputFile(root + "/"
            .concat("_")
            .concat(generateUniqueFileName())
            .concat(".amr"));


    try {
        recorder.prepare();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    recorder.start();
}

我已经获得了所有需要的 android 录制权限,但它在 android 6.0.1 以上版本中无法正常工作。提前感谢您的解决方案...

【问题讨论】:

  • 请添加比“无法正常工作”更详细的问题描述。
  • 通话持续 1 分钟,但录音会在几秒后立即停止,即以上版本为 3 秒...
  • 对于 6.0.1 以上的版本是否需要在此代码中添加? @迈克尔
  • startActivity(i); 如果失败,则会发生异常,并在尝试audioRecord();时失败
  • 解决方案是什么@t0mm13b?

标签: android audio-recording mediarecorder android-mediarecorder voice-recording


【解决方案1】:

您是在 Service 还是 Activity 中使用通话录音代码?

一旦开始通话记录,活动填充就会停止,因此如果您的代码处于活动状态,通话记录将停止。

【讨论】:

  • yaa 通话录音正在进行中,那么为什么录音在棒棒糖版本中运行良好?
【解决方案2】:

Android 7 不支持语音通话使用 micro

recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多