Is there a problem in recording calls and is not supported in Android 7.0?

enter image description here

Problem: Call recording works fine until Android 6.0.1 , but it doesn’t work properly on this version of Android.

Problem: - the call is on for 1 minute, but recording stops after 2 - 3 seconds.

Here's the Edittext of Contact:

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;
        }
    });
}

Here is the basic code for recording calls.

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

I accepted all the necessary permissions for writing to Android, but it does not work in versions of android 6.0.1. Thanks in advance for the decision ...

+4
source share
1 answer

?

, , , .

0

Source: https://habr.com/ru/post/1679054/


All Articles