mRecorder.prepare();
mRecorder.start();
Thread auto_stop=new Thread(new Runnable()
{
@Override
public void run() {
try {
Thread.sleep(30000);
if(WavAudioRecorder.flag)
{
mRecorder.stop();
mRecorder.reset();
btnControl.setText("Start");
return ;
}
} catch (InterruptedException e) {
//e.printStackTrace();
}
}
});
auto_stop.start();
我試圖做一個記錄器應用程序,記錄30秒,並停止。我使用上面提到的代碼停止記錄器。該應用程序在錄製30秒後崩潰。如何崩潰的部分得到解決? 我用於啓動和停止的代碼是link。秒應用程序在錄製後崩潰
04-23 09:53:34.955: E/AndroidRuntime(4278): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4746)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:823)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.view.View.requestLayout(View.java:15468)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.view.View.requestLayout(View.java:15468)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.view.View.requestLayout(View.java:15468)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.view.View.requestLayout(View.java:15468)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.view.View.requestLayout(View.java:15468)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.widget.TextView.checkForRelayout(TextView.java:6313)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.widget.TextView.setText(TextView.java:3567)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.widget.TextView.setText(TextView.java:3425)
04-23 09:53:34.955: E/AndroidRuntime(4278): at android.widget.TextView.setText(TextView.java:3400)
04-23 09:53:34.955: E/AndroidRuntime(4278): at com.example.androidwaverecorder.MainActivity$1$1.run(MainActivity.java:53)
04-23 09:53:34.955: E/AndroidRuntime(4278): at java.lang.Thread.run(Thread.java:856)
你可以使用處理程序... – Triode 2013-04-23 09:47:06
我只是一個初學者,所以請你能詳細告訴我 – 2013-04-23 09:48:04
從logcat stacktrace請嗎? – 2013-04-23 09:49:34