java – Error when I try to build call recording application with root-ThrowExceptions

Exception or error:

I have some problem with create call recording application. I know that this is
impossible for an ordinary android, but I have root privileges.
I have this permissions in Manifest file:

        <uses-permission android:name="android.permission.CALL_PHONE" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        <uses-permission android:name="android.permission.RECORD_AUDIO" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_CONTACTS" />
        <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
        <uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>
        <uses-permission android:name="android.permission.READ_CALL_LOG"/>
        <uses-permission android:name="android.permission.ANSWER_PHONE_CALLS"/>
        <uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT"/>
        <uses-permission android:name="android.permission.RECORD_AUDIO" />
        <uses-permission android:name="android.permission.STORAGE" />

and I use:

 callrecorder = new MediaRecorder();
            callrecorder.setAudioSource(MediaRecorder.AudioSource.CALL_PHONE);
            callrecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
            callrecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            callrecorder.setOutputFile(Environment.getExternalStorageDirectory() + "/Download/file.amr");

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

And I have Error:


System.err: java.lang.RuntimeException: start failed.
System.err:     at android.media.MediaRecorder.start(Native Method)
System.err:     at RecordAnswer.doInBackground(RecordAnswer.java:24)
System.err:     at android.os.AsyncTask$3.call(AsyncTask.java:378)
System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
System.err:     at java.lang.Thread.run(Thread.java:919)

When I use for example


callrecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);

it’s OK.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *