So I am making a android app and for that I want to update my progressBar Automatically at each second but it isn't working like that.Instead it's calling the function only once .
private int progress=1;
private CountDownTimer countDownTimer;
private boolean mTimerRunning=true;
private long mTimeLeft=START;
ProgressBar progressBar;
private void startTimer(){
countDownTimer=new CountDownTimer(mTimeLeft,1000) {
@Override
public void onTick(long l) {
mTimeLeft=l;
updateText();
updateProgressBar();
}
@Override
public void onFinish() {
}
}.start();
mTimerRunning=true;
button.setText("Pause");
}
private void updateText(){
int minutes=(int) (mTimeLeft/1000)/60;
int seconds=(int) (mTimeLeft/1000)%60;
String timeLeft=String.format("%02d:%02d",minutes,seconds);
textView.setText(timeLeft);
}
private void updateProgressBar()
{
progressBar.setProgress(progress+1);
}