I tried to change my UI from my TimerTask and I recognized that it is impossible, because the TimerTask runs in a background thread and background threads are not allowed to change the UI.
Now my question is: I was changing a ProgressBar and a TextView from the TimerTask, and it worked for the ProgressBar but not for the TextView. Why is it possible for me to change the ProgressBar?
Why doesn't the ProgressBar have any problems with this?
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
int time = playerTimer(time);
progressbar.setProgress(time);
playerTime.setText(time);
}
}, 0, 1000);