Back to project page notes.
The source code is released under:
Apache License
If you think the Android project notes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.donnemartin.android.notes.notes; // w ww . ja v a 2 s . c o m import android.media.MediaRecorder; import android.util.Log; import java.io.IOException; public class AudioRecorder { private MediaRecorder mRecorder; private static String mFileName; private boolean mIsRecording; private static final String LOG_TAG = "AudioRecorder"; public AudioRecorder(String fileName) { mFileName = fileName; } public boolean isRecording() { return mIsRecording; } public void startRecording() { mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mRecorder.setOutputFile(mFileName); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); try { mRecorder.prepare(); } catch (IOException e) { Log.e(LOG_TAG, "prepare() failed"); } mRecorder.start(); mIsRecording = true; } public void stopRecording() { mRecorder.stop(); mRecorder.release(); mRecorder = null; mIsRecording = false; } }