开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜