stop() called on an uninitialized AudioRecord.
See original GitHub issueHi, I am using this library and when I am recording second time and stopping, I am getting below error. Please suggest. Thank You.
Error is
java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
**Code to start and stop **
`View.OnTouchListener touchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (permissionToRecordAccepted && permissionToReadExternalStorage && permissionToWriteExternalStorage) {
//startPulseAnimation();
timerTextView.setVisibility(View.VISIBLE);
countDownTimer.start();
recorder.startRecording();
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
timerTextView.setVisibility(View.INVISIBLE);
countDownTimer.cancel();
try {
recorder.stopRecording(); // Here I am getting error.
if (!TextUtils.isEmpty(mVerificationId)) {
mPresenter.configureVoice(mVerificationId, Utility.getDeviceId(), file().getPath(), audioBytes);
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
}`
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
startRecording() called on an uninitialized AudioRecord
IllegalStateException: startRecording() called on an uninitialized AudioRecord. But when i set the audiosource to "MIC", it works fine, ...
Read more >How to catch exception thrown from AudioRecord Class in ...
When i am trying to stop the AudioRecord class using JNI jmethodID method_id; ... startRecording() called on an uninitialized AudioRecord.
Read more >Java – startRecording() called on an uninitialized AudioRecord
i am trying to record voice call on android. I am using AudioRecord class/api of android to perform this. But for some reason...
Read more >media/java/android/media/AudioRecord.java - Google Git
throw new IllegalStateException("stop() called on an uninitialized AudioRecord."); } // stop recording. synchronized(mRecordingStateLock) {.
Read more >android.media.AudioRecord#STATE_INITIALIZED
VISIBLE); } else { uncaughtException(Thread.currentThread(), new IllegalStateException ("startRecording() called on an " + "uninitialized AudioRecord.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
from AOSP,
after
stop
is called,mState = STATE_UNINITIALIZED;
fromstartRecording
,mState
only resets from the constructor => construct new object for second recordjava.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
You will get this error only when the AudioRecord object is not properly intialized. It may happen if you use stopRecording() before calling startRecording().