I'm trying to record sound on android, using code basically just copied from the developer docs, here it is:
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/audiorecordtest.3gp";
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
I get a runtime exception on开发者_如何学运维 the 4th line, I@m not sure why. Could you help?
Top tip: - Always check you've given your app the appropriate permissions! I forgot to let my app record sound.
精彩评论