How to record a audio in Android and save it in Database?
Hi I am making an Android app for recording a audio for 5-10 sec and store that in Database. For audio recording i follow this http://xhampa.pastebin.com/Yr2hie6q
开发者_运维百科But it is not working properly. What to do ? I can not record the Audio on my G1 mobile. Any suggestion welcome.
For your audio recording, try this code:
MediaRecorder recorder;
public void startRecording() throws IOException
{
SimpleDateFormat timeStampFormat = new SimpleDateFormat(
"yyyy-MM-dd-HH.mm.ss");
String fileName = "audio_" + timeStampFormat.format(new Date())
+ ".mp4";
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile("/sdcard/"+fileName);
recorder.prepare();
recorder.start();
}
protected void stopRecording() {
recorder.stop();
recorder.release();
}
You can find your file on your sdcard.
精彩评论