Java – The default recording in Android

The default recording in Android… here is a solution to the problem.

The default recording in Android

I noticed that the Android default recorder senses your voice and show it to you in UI parameter .

Can I use it from Intent? Or how do I write a code to sense sound loudness in Android.

Solution

You can use Android android.media.MediaRecorder to record. This page lists all APIs http://developer.android.com/reference/android/media/MediaRecorder.html. This should solve all your problems.
Sample code

 MediaRecorder recorder = new MediaRecorder();
 recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
 recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
 recorder.setOutputFile(PATH_NAME);
 recorder.prepare();
 recorder.start();    Recording is now started
 ...
 while(recordingNotOver)
 {
    int lastMaxAmplitude = recorder.getMaxAmplitude();
     you have the value here in lastMaxAmplitude, do what u want to
 }

recorder.stop();
 recorder.reset();    You can reuse the object by going back to setAudioSource() step
 recorder.release();  Now the object cannot be reused

Related Problems and Solutions