嗨,我是新的android和在我的应用程序我使用进度条为此录音为此,当我开始录制我正在更新进度栏,这很好,在这里,当我停止录音进度没有停止它的连续更新,请帮我有人如何停止进度,当我停止录音如何停止进度条,当我们停止处理程序android
private void startRecording() {
try {
handler = new Handler();
recorderProgressBar = (ProgressBar) dialog.findViewById(R.id.recorder_progressBar);
progressStatus = 0;
// Start the lengthy operation in a background thread
thread = new Thread() {
@Override
public void run() {
while (progressStatus < 100) {
// Update the progress bar
if (handler != null) {
// Update the progress status
progressStatus += 1;
// Try to sleep the thread for 20 milliseconds
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
handler.post(runnable);
}
}
}
};
thread.start();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
Runnable runnable = new Runnable() {
public void run() {
System.out.println("it's calling ramakrishna");
recorderProgressBar.setProgress(progressStatus);
}
};
private void stopRecording() {
//Kill Background thread
if (handler != null) {
handler.removeCallbacks(runnable);
}
}
OK,让我试着告诉你导致 – Krish
没有连我初始化处理程序时活动开始进度更新 – Krish
请让我知道solutiuon – Krish