How to get the amplitude when blowing into MIC on android device
<p>How to get the amplitude when blowing into MIC in android device.</p>

<pre><code>MediaRecorder recorder = new MediaRecorder();
   recorder.setAudioSource(MediaRecorder.AudioSource.MIC);

   Timer timer = new Timer();
   timer.scheduleAtFixedRate(new RecorderTask(recorder), 0, 1000);

private class RecorderTask extends TimerTask {
private MediaRecorder recorder;

public RecorderTask(MediaRecorder recorder) {
    this.recorder = recorder;
}

public void run() {
    Log.v("", "amplitude is" + recorder.getMaxAmplitude());
}
}
</code></pre>

<p>I am getting an error: </p>

<pre><code>ERROR/AndroidRuntime(20927): Caused by: java.lang.RuntimeException: setAudioSource failed.
ERROR/AndroidRuntime(20927): at android.media.MediaRecorder.setAudioSource(Native Method)
</code></pre>
