我有android G1固件1.6,我试图用以下代码从应用程序录制语音.
MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(PATH_NAME); recorder.prepare(); recorder.start();
我的manifest.xml有:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
我有:
09-23 14:41:05.531: ERROR/AndroidRuntime(1718): Uncaught handler: thread main exiting due to uncaught exception 09-23 14:41:05.551: ERROR/AndroidRuntime(1718): java.lang.RuntimeException: setAudioSource failed. 09-23 14:41:05.551: ERROR/AndroidRuntime(1718): at android.media.MediaRecorder.setAudioSource(Native Method)
我该如何正确录制声音?
我正试图通过小型录音从服务中找到声压级,但Android不会让我访问硬件.我在Logcat中收到以下错误:

该错误来自以下代码:
AudioRecord recordInstance = null;
// We're important...
android.os.Process
.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
short bufferSize = 4096;// 2048;
recordInstance = new AudioRecord(MediaRecorder.AudioSource.MIC, this //line 167
.getFrequency(), this.getChannelConfiguration(), this
.getAudioEncoding(), bufferSize); //object not created
tempBuffer = new short[bufferSize];
recordInstance.startRecording();
Run Code Online (Sandbox Code Playgroud)
会发生什么是recordInstance从未正确创建,所以当它到达结尾并调用recordInstance.startRecording()时,recordInstance仍为null.Android在定义中拒绝我的程序请求.有谁知道这些错误表明了什么?我在网上找不到列表.
谢谢