Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import android.media.MediaRecorder; public class Main { /** * Then call recorder.start(); * @param audiofile * @param format MediaRecorder.OutputFormat.THREE_GPP - ".3gp" * @throws Exception * @return MediaRecorder */ public static MediaRecorder startRecordAction(File audiofile, int format) throws Exception { MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(format); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(audiofile.getAbsolutePath()); recorder.prepare(); return recorder; } }