我不硝酸鉀爲什麼,但在start()方法拋出一個錯誤和崩潰的應用程序:Android的錄音機啓動無效狀態4
public class Noise extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.noise);
MediaRecorder recorder=new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try{
recorder.prepare();
}catch(IllegalStateException e){
Log.d("Error",e.toString());
e.printStackTrace();
}catch(IOException e){
Log.d("Error",e.toString());
e.printStackTrace();
}
recorder.start();
Timer timer=new Timer();
timer.scheduleAtFixedRate(new RecorderTask(recorder), 0, 500);
}
private class RecorderTask extends TimerTask{
TextView risultato=(TextView) findViewById(R.id.risultato_recorder);
private MediaRecorder recorder;
public RecorderTask(MediaRecorder recorder){
this.recorder = recorder;
}
public void run(){
runOnUiThread(new Runnable() {
@Override
public void run() {
risultato.setText("" + recorder.getMaxAmplitude());
}
});
}
}
}
如果我刪除的準備和啓動,它工作,但總是返回0在textview中。 任何人都可以幫助我?這件事情讓我瘋狂
這是logcat的:https://dl.dropbox.com/u/16047047/log.txt
,並在手機,它崩潰。
什麼是錯誤(堆棧跟蹤)是由start()方法拋出? – Veger
我已經添加了logcat中的主要問題 – Zak