android setAudioSource failed
android setAudioSource failed
(2011-05-20 17:14:52) 转载▼ 标签: 杂谈 | 分类: android |
录音的步骤:
mRecAudioPath=Environment.getExternalStorageDirectory();
File mRecAudioFile=File.createTempFile(strTempFile, ".amr",mRecAudioPath);
mMediaRecorder=new MediaRecorder();
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);//Call this only before setOutputFormat().这里很重要,如果在setOutputFormat的后面调用的话,会报异常!
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mMediaRecorder.setOutputFile(mRecAudioFile.getAbsolutePath());
mMediaRecorder.prepare();
mMediaRecorder.start();
采用上面的步骤运行后,后台报了异常:
ERROR/AndroidRuntime(287): java.lang.RuntimeException: setAudioSource failed.
原因:权限问题
在AndroidManifest.xml文件中添加:
更多相关文章
- Android中蓝牙使用步骤小结
- android Log.isLoggable步骤的使用
- android Log.isLoggable步骤的使用
- Android(安卓)Studio 运行 java,找不到或无法加载主类
- Android中蓝牙使用步骤小结
- android 一个奇怪的bug
- Android中蓝牙使用步骤小结
- Android中蓝牙使用步骤小结
- Android中蓝牙使用步骤小结