更高版本的呼叫记录问题

时间:2017-06-13 11:53:30

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

问题在于,录制正在进行到Android 6.0版本,但无法在该版本之上正常工作,即调用最多1分钟,但录制在2到3秒内停止。

我已经获得了录音通话的所有权限。

这里是联系人的Edittext:

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() >= (contact.getRight() - contact.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                if (!contact.getText().toString().isEmpty()) {

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

                    try {
                        Record();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

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

CallRecording编码如下:

private void Record() 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();
}

将感激解决。

0 个答案:

没有答案
相关问题