the part of the code that throws exception:
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
recorder.setOutputFile("test.3gp");
recorder.prepare();
recorder.start();
and i'm getting this exception:
E/MediaRecorder: start failed: -38
W/System.err: java.lang.IllegalStateException
W/System.err: at android.media.MediaRecorder.start(Native Method)
W/System.err: at com.example.amit.recording.RecordService.startRecording(RecordService.java:280)
W/System.err: at com.example.amit.recording.RecordService.onStartCommand(RecordService.java:141)
W/System.err: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3422)
W/System.err: at android.app.ActivityThread.access$2200(ActivityThread.java:181)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1572)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err: at android.os.Looper.loop(Looper.java:145)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6117)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
the "recorder.start()" is causing this. also when i'm stopping the record, getting this: "stop called in an invalid state: 0" btw - got all the permissions i need in the manifest. thanks!!
EDIT
i added "Thread.sleep(2000);" before "prepare()" & "start()", and now it saved a 3gp file in the correct path, but the exceptions are still there - on start() & on stop(). why is it happening?!