Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CountDownTimer updating and blocking

If understand CountDownTimer correctly, it doesn't run on a separate thread from the activity that started it. So does that mean if I start a CountDownTimer in my main activity, and another piece of code later blocks in the activity, does this mean the CountDownTimer will no longer update as the thread is tied up?

and if so, would the CountDownTimer attached to the main activity also stop updating if I launch a second activity?

like image 899
Spoonface Avatar asked Nov 04 '22 17:11

Spoonface


1 Answers

If the CountdownTimer is started in the main thread, then any blocking call in the main thread will delay the Ontick and Onfinish().

But the second part is not true, since even if the next activity is started, the main thread is still running. So the CountdownTimer will continue to run even if you launch the second activity

like image 123
nandeesh Avatar answered Nov 13 '22 15:11

nandeesh