I am working in android. How can I record an audio file through microphone, and how can I save the recorded file in the emulator?
You can record audio on Android using an easy-to-use built-in audio recording app on most devices, though the exact app tends to differ device to device.
QUICK ANSWERUse your phone's microphone and an audio recorder app to record external audio on Android. You can use the phone's built-in screen recorder feature or download an app from the Google Play Store to record internal audio.
It is easy to record audio in Android. What you need to do is:
1) Create the object for media record class : MediaRecorder recorder = new MediaRecorder();
2) In the emulator, you're unable to store the recorded data in memory, so you have to store it on the SD Card. So, first check for the SD Card availability: then start recording with the following code.
String status = Environment.getExternalStorageState(); if(status.equals("mounted")){ String path = your path; } recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); recorder.start();
3) To stop, override stop method of activity
recorder.stop(); recorder.release();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With