Reputation: 461
I want to use the mediarecorder
in my app to record voice.
I do exactly what is described under http://developer.android.com/reference/android/media/MediaRecorder.html but the exception
is always thrown in the start()
method.
The code should be fine, as I also tried out the code example called Mediarecorder
from google but I get the same exception:
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(TAG, "prepare() failed");
}
mRecorder.start();
I have already added the permissions (android.permission.WRITE_EXTERNAL_STORAGE and android.permission.RECORD_AUDIO
) to the AndroidManifest.xml,
and I start the app on my connected smartphone.
Does anybody know what might cause the Exception
and what one has to do?
Upvotes: 1
Views: 88
Reputation: 461
Thanks for your comments. I was able to resolve the issue. I had in fact a missing mRecorder.release() and so it seems that the start method was called twice.
Upvotes: 1