Android的CountDownTimer [英] Android CountDownTimer
本文介绍了Android的CountDownTimer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当写:
CountDownTimer timer = new CountDownTimer(1000, 100)
{
@Override
public void onTick(long l)
{
}
@Override
public void onFinish()
{
};
}.start();
在我们真正开始处理蜱一个新线程?如果不是,究竟发生什么事?
are we actually starting a new thread that handles ticks? If not, what is really happening?
推荐答案
CountDownTimer
的<一个href="http://www.google.com/$c$csearch/p?hl=en#uX1GffpyOZk/core/java/android/os/CountDownTimer.java&q=package%3aandroid%20CountDownTimer&sa=N&cd=1&ct=rc">implementation使用处理程序
和 sendMessageDelayed()
,所以没有后台线程是必要的。这也意味着,如果你在你的code占用主应用程序线程在其他地方的计时器将不会更新。
CountDownTimer
's implementation uses Handler
and sendMessageDelayed()
, so no background thread is needed. This does mean that the timer will not update if you are tying up the main application thread elsewhere in your code.
这篇关于Android的CountDownTimer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文