In this code snippet, the application sleeps for the interval, but instead of appending TEXT to textStatus(TextView variable), it displays an error that Something went wrong and application is closing.
Thread time_manager = new Thread(){
public void run(){
int interval = 2000;
try{
sleep(interval);
textStatus.append("\nTEXT\n");
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
}
}
};
What part am I doing wrongly?
To update the UI you can also use Handler like this, it will update your UI incrementing the value of counter everytime by 1 within every second.