我发现的代码如下
MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); ***<== ERROR*** recorder.setoutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setoutputfile("/sdcard/sample.3gp"); recorder.setonErrorListener(errorListener); recorder.setonInfoListener(infoListener); try { recorder.prepare(); recorder.start(); } catch (IllegalStateException e) { e.printstacktrace(); } catch (IOException e) { e.printstacktrace(); }
我正在使用AndroID API 2.1
解决方法 您可以找到最好的例子: http://developer.android.com/guide/topics/media/index.html#capture我希望你在手机上测试它,因为:
Note that the emulator doesn’t have harDWare to capture audio or vIDeo,but actual mobile devices are likely to provIDe these capabilitIEs,accessible through the MediaRecorder class.
看看这个:
/* * The application needs to have the permission to write to external storage * if the output file is written to the external storage,and also the * permission to record audio. These permissions must be set in the * application's AndroIDManifest.xml file,with something like: * * <uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE" /> * <uses-permission androID:name="androID.permission.RECORD_AUdio" /> */总结
以上是内存溢出为你收集整理的android – 由于recorder.setAudioSource(MediaRecorder.AudioSource.MIC)导致的Forceclose错误;全部内容,希望文章能够帮你解决android – 由于recorder.setAudioSource(MediaRecorder.AudioSource.MIC)导致的Forceclose错误;所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)