Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the microphone on Android

Tags:

android

I have just started to develop my first Android app, and I am having a hard time figuring out how to start the microphone and have it listen, which is a main feature of my app.

I've searched the Android docs and I can't find much info on this.

Thanks in advance.

like image 694
novicePrgrmr Avatar asked Jul 03 '11 17:07

novicePrgrmr


1 Answers

Maybe this can help (actually from the Android docs):
Audio Capture

  1. Create a new instance of android.media.MediaRecorder.
  2. Set the audio source using MediaRecorder.setAudioSource(). You will probably want to use MediaRecorder.AudioSource.MIC.
  3. Set output file format using MediaRecorder.setOutputFormat().
  4. Set output file name using MediaRecorder.setOutputFile().
  5. Set the audio encoder using MediaRecorder.setAudioEncoder().
  6. Call MediaRecorder.prepare() on the MediaRecorder instance.
  7. To start audio capture, call MediaRecorder.start().
  8. To stop audio capture, call MediaRecorder.stop().
  9. When you are done with the MediaRecorder instance, call MediaRecorder.release() on it. Calling MediaRecorder.release() is always recommended to free the resource immediately.

or:
Android Audio Recording Tutorial

like image 72
Magnus Johansson Avatar answered Oct 24 '22 09:10

Magnus Johansson