title: Android MediaRecorder - IllegalStateException
body: <p>the part of the code that throws exception:</p>
  
  <pre><code>        recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
          recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
          recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
  
          recorder.setOutputFile("test.3gp");
          recorder.prepare();
          recorder.start();
  </code></pre>
  
  <p>and i'm getting this exception:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>the "recorder.start()" is causing this. also when i'm stopping the record, getting this: <strong>"stop called in an invalid state: 0"</strong>
  btw - got all the permissions i need in the manifest. thanks!!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>i added "Thread.sleep(2000);" before "prepare()" &amp; "start()", and now it saved a 3gp file in the correct path, but the exceptions are still there - on start() &amp; on stop(). why is it happening?!</p>