Hi,
In this tutorial I just going to tell you how to record audio in android
initialise media player instance
private MediaRecorder mRecorder;
record audio function
public void startRecord() {
File fileFolder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "inward");
fileName = new File(fileFolder, "inward_rocording.mp3");
if (!fileFolder.exists()) {
fileFolder.mkdir();
}
if (!fileName.exists()) {
try {
fileName.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mRecorder.setOutputFile(fileName);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e("Recording failed", e.getLocalizedMessage());
}
mRecorder.start();
}
stop record function
public void stopRecord() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}