Android examples for android.media:Audio
start Recording Audio
import android.content.Context; import android.media.MediaRecorder; import android.util.Log; public class Main { private static MediaRecorder mRecorder; private static String mFileName; public static void startRecordingAudio(Context ctx) { mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mFileName = "yourName.mp3"; mRecorder.setOutputFile(mFileName);//w w w .j ava 2s .co m mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); try { mRecorder.prepare(); mRecorder.start(); } catch (Exception e) { Log.e("", " failed" + e.getMessage()); } } }