title: java.lang.IllegalStateException at android.media.MediaRecorder
body: <p>I am trying to record sound using microphone. The code works perfectly on <strong>Samsung Note 2 (N7100)</strong> however I receive some errors on some devices. What is the mean of these errors? My codes below here. Thanks in advance.</p>
  
  <pre><code>    private void startRecording() {
      CharSequence now = android.text.format.DateFormat.format("dd-MM-yyyy HH:mm:ss", new Date());
      String outputFile = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "The Looppad"
              + File.separator + now + ".3gp";
      mRecorder = new MediaRecorder();
      mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
      mRecorder.setAudioSamplingRate(44100);
      mRecorder.setAudioEncodingBitRate(96000);
      mRecorder.setOutputFile(outputFile);
      try {
          mRecorder.prepare();
      } catch (IllegalStateException | IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      mRecorder.start();
      record.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
      isRecording = true;
  }
  </code></pre>
  
  <p><strong>Errors:</strong></p>
  
  <p><em>Error on General Mobile Android 4.2</em></p>
  
  <pre><code>java.lang.IllegalStateException
  at android.media.MediaRecorder.start(Native Method)
  at org.uusoftware.thelaunchpadhouse.ActivityFutureHouse.m(Unknown Source)
  at org.uusoftware.thelaunchpadhouse.ActivityFutureHouse.onOptionsItemSelected(Unknown Source)
  at android.app.Activity.onMenuItemSelected(Activity.java:2566)
  at android.support.v4.b.ab.onMenuItemSelected(Unknown Source)
  at android.support.v7.a.ag.onMenuItemSelected(Unknown Source)
  at android.support.v7.view.n.onMenuItemSelected(Unknown Source)
  at android.support.v7.a.as.a(Unknown Source)
  at android.support.v7.view.menu.i.a(Unknown Source)
  at android.support.v7.view.menu.m.b(Unknown Source)
  at android.support.v7.view.menu.i.a(Unknown Source)
  at android.support.v7.view.menu.i.a(Unknown Source)
  at android.support.v7.widget.ActionMenuView.a(Unknown Source)
  at android.support.v7.view.menu.ActionMenuItemView.onClick(Unknown Source)
  at android.view.View.performClick(View.java:4211)
  at android.view.View$PerformClick.run(View.java:17446)
  at android.os.Handler.handleCallback(Handler.java:725)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:153)
  at android.app.ActivityThread.main(ActivityThread.java:5336)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p><em>Error on LG G2 Android 4.4</em></p>
  
  <pre><code>java.lang.IllegalStateException
  at android.media.MediaRecorder.native_start(Native Method)
  at android.media.MediaRecorder.start(MediaRecorder.java:758)
  at org.uusoftware.thelaunchpadhouse.ActivityTechnoHouse.m(Unknown Source)
  at org.uusoftware.thelaunchpadhouse.ActivityTechnoHouse.onOptionsItemSelected(Unknown Source)
  at android.app.Activity.onMenuItemSelected(Activity.java:2644)
  at android.support.v4.b.ab.onMenuItemSelected(Unknown Source)
  at android.support.v7.a.ag.onMenuItemSelected(Unknown Source)
  at android.support.v7.view.n.onMenuItemSelected(Unknown Source)
  at android.support.v7.a.as.a(Unknown Source)
  at android.support.v7.view.menu.i.a(Unknown Source)
  at android.support.v7.view.menu.m.b(Unknown Source)
  at android.support.v7.view.menu.i.a(Unknown Source)
  at android.support.v7.view.menu.i.a(Unknown Source)
  at android.support.v7.widget.ActionMenuView.a(Unknown Source)
  at android.support.v7.view.menu.ActionMenuItemView.onClick(Unknown Source)
  at android.view.View.performClick(View.java:4442)
  at android.view.View$PerformClick.run(View.java:18473)
  at android.os.Handler.handleCallback(Handler.java:733)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:136)
  at android.app.ActivityThread.main(ActivityThread.java:5105)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>