Code example for AudioRecord

Methods: getRecordingStategetStatereadstartRecordingstop

0
		return tmpData;
	} 
 
	  private byte[] fillBuffer(byte[] audioData, int bufferSize) {
 
		    AudioRecord recorder = new AudioRecord(AudioSource.MIC, 8000, AudioFormat.CHANNEL_IN_MONO,
		            AudioFormat.ENCODING_PCM_16BIT, bufferSize); // instantiate the
		                                                            // AudioRecorder 
		    if (recorder.getRecordingState() == android.media.AudioRecord.RECORDSTATE_STOPPED)
		        recorder.startRecording(); // check to see if the Recorder
		                                    // has stopped or is not 
		                                    // recording, and make it 
		                                    // record. 
 
		    recorder.read(audioData, 0, bufferSize); // read the PCM
		                                                // audio data 
		                                                // into the 
		                                                // audioData 
		                                                // array 
 
		    if (recorder.getState() == android.media.AudioRecord.RECORDSTATE_RECORDING)
		        recorder.stop(); // stop the recorder
 
		    return audioData;
 
		}