以下代码在2.1中没有问题,private void startRecord(Context context, Intent intent){
String path = intent.getStringExtra(AndrecorderContactHelper.FILEPATH);
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
//
String _type = AndrecorderConfiguration.getConfiguration(context).getRecordType();
int format = OutputFormat.DEFAULT;
if (_type.equalsIgnoreCase("amr"))
format = OutputFormat.RAW_AMR;
else if (_type.equalsIgnoreCase("3gp"))
format = OutputFormat.THREE_GPP;
else if (_type.equalsIgnoreCase("mp4"))
format = OutputFormat.MPEG_4;
recorder.setOutputFormat(format);
recorder.setAudioEncoder(AAC);
recorder.setOutputFile(path);
try {
recorder.prepare();
recorder.start();
} catch (IllegalStateException e) {

e.printStackTrace();
} catch (IOException e) {

e.printStackTrace();
}

//
Log.i("whut", "开始录音");
recording = true;
}
但是在2.3中recorder.start()处就会出错.
logcat窗口提示 start failed: -22
在网上照了一些资料也没有看到解决的方案.
在此求助了.

解决方案 »

  1.   

    有在AndroidManifest.xml文件里添加录音权限吗?
      

  2.   

    得看看在hal层有没有call到,有没有正确调用到录音设备通路、参数等。
      

  3.   

    录音权限有,因为2.1中录音文件能播放.孙德生说的hal层有没有call,有没有正确调用录音设备这个,我不怎么清楚.
    你能详细介绍下么?
      

  4.   

    看了一些外文的资料.
    尤其是xda-developer上说了,一般的ROM在2.2和2.3都禁止通话录音.
    只有修改的ROM,如果机子自带通话录音的话,这个VOICE_CALL才有用.
      

  5.   

    recorder.setAudioEncoder(AAC);我很想知道你这行代码中AAC 这个参数的值是什么东西来的