I am getting this error when i try to run the code at android 6.0 device
AudioFlinger could not create record track, status: -1 Error creating AudioRecord instance: initialization check failed with status -1.
I have this code which works well on lower version device
private void startRecording()
{
bufferSize = AudioRecord.getMinBufferSize(11025,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT);
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
11025, AudioFormat.CHANNEL_CONFIGURATION_MONO,
RECORDER_AUDIO_ENCODING, 1024);
int i = recorder.getState();
if (i==1)
{
recorder.startRecording();
ShowToast("Recording started successfully");
}
isRecording = true;
recordingThread = new Thread(new Runnable()
{
@Override
public void run()
{
writeAudioDataToFile();
}
}, "AudioRecorder Thread");
recordingThread.start();
}