Код: Выделить всё
audioRecord.startRecording();
isReading = true;
totalSizeInBytes = 0;
new Thread(new Runnable() {
@Override
public void run() {
short[] buffer = new short[bufferSize]; //buffer of shorts, getting from audioRecord
int readCount;
int state;
int check = 0;
//wakeLock initialization and acquiring
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyApp:RecordWakeLock");
wakeLock.acquire();
if (isWavFileCreated) {
while (isReading) {
Log.d(TAG, audioRecord.getRecordingState() + "");
readCount = audioRecord.read(buffer, 0, bufferSize);
writeWavFile(buffer);
}
writeWavFileHeader();
try {
dos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}).start();
Подробнее здесь: https://stackoverflow.com/questions/546 ... en-i-use-w