问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/12146783/countdowntimer-updating-and-blocking