嗨,我是新的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