0

There is a way to check if microphone on Android phone is recording anything? I didn't find anything in AudioRecorder.
Update:

int sampleRateInHz = 8000;//8000 44100, 22050 and 11025
int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_MONO;
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
int bufferSize = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);


public int getRecordingState() {
    AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRateInHz, channelConfig, audioFormat, bufferSize);
    return audioRecord.getRecordingState();
}
Kirill
  • 1,530
  • 5
  • 24
  • 48

1 Answers1

0

I saw a number of things you could try. From AudioRecord - getRecordingState() - Returns the recording state of the AudioRecord instance.

Or you can try testing: read(byte[], int, int), read(short[], int, int) or read(ByteBuffer, int) methods to see if the buffers are growing in size.

Edit: Here are some examples on how to read the buffer and an explanation:

Understanding of the Audio Recorder read() buffer

Android AudioRecord example

Community
  • 1
  • 1
Kristy Welsh
  • 7,828
  • 12
  • 64
  • 106
  • So I wrote the method (see update please). Doesn't look like work either. It always returns 1, i.e. int RECORDSTATE_STOPPED... – Kirill Dec 11 '14 at 22:19