Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android MediaRecorder启动失败-2147483648在2.3上工作,但在4.0上未工作_Android_Service_Android Mediarecorder - Fatal编程技术网

Android MediaRecorder启动失败-2147483648在2.3上工作,但在4.0上未工作

Android MediaRecorder启动失败-2147483648在2.3上工作,但在4.0上未工作,android,service,android-mediarecorder,Android,Service,Android Mediarecorder,该代码在android2.3上运行良好,但在4.0上不起作用。它在recorder.start()上出现错误,我对此完全空白 任何与此相关的建议都将被接受,提前谢谢 试试这个也许会有帮助 audiofile = File.createTempFile(file_name, ""+audio_format, sampleDir); String path=Environment.getExternalStorageDirectory().getAbsolutePath(); audioSourc

该代码在android2.3上运行良好,但在4.0上不起作用。它在recorder.start()上出现错误,我对此完全空白 任何与此相关的建议都将被接受,提前谢谢

试试这个也许会有帮助

audiofile = File.createTempFile(file_name, ""+audio_format, sampleDir);
String path=Environment.getExternalStorageDirectory().getAbsolutePath();

audioSource = MediaRecorder.AudioSource.MIC;

recorder=new MediaRecorder();
recorder.setAudioSource(audioSource);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
recorder.setOutputFile(audiofile.getAbsolutePath()); 

//recorder.prepare(); 
//recorder.start();
//Handle IOException

  recorder.prepare();

  recorder.start();
  Log.d("TAG", "recording started");
private MediaRecorder mRecorder = null;
 private static final String LOG_TAG = "MediaAudioCapture";
 ImageButton button_audio_button = (ImageButton) findViewById(R.id.audio_button);
  button_audio_button.setOnClickListener(new OnClickListener() {
  public void onClick(View record_button) {
  ImageButton audio_button = (ImageButton) record_button;
  if (!started_note_recording) {
    if (!started_recording) {
      startRecording();
      audio_button.setImageResource(R.drawable.audio_red);
     } else {
     stopRecording();
     audio_button.setImageResource(R.drawable.audio);
     }
    }
  }
 });
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setOutputFile(output.getAbsolutePath());
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
ImageButton button_audio_button = (ImageButton)findViewById(R.id.audio_button);
button_audio_button.setImageResource(R.drawable.audio);
 }
}
});
 try {
  mRecorder.prepare();
 } catch (IOException e) {
 Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
stopWatch.start();
}