CountDownTimer updating and blocking

自作多情 提交于 2019-12-10 15:37:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!