已经从 onCreate 方法启动了我的计时器。即使我的活动停止,计时器也会继续运行。怎么可能?
onTick() 方法显示 Toast,Thread 为主线程。我想,当 Activity 停止时,主线程会停止。任何人都可以对此进行解释。
CustomCountDownTimer.java
private class CustomCountDownTimer extends CountDownTimer
{
public CustomCountDownTimer(long millisInFuture,long countDownInterval)
{
super(millisInFuture,countDownInterval);
}
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
long seconds=millisUntilFinished/1000;
long hours=seconds/(60*60);
long remainingSeconds=seconds%(60*60);
long minutes=remainingSeconds/60;
remainingSeconds=remainingSeconds%60;
Toast.makeText(HomeActivity.this, Thread.currentThread().getName()+"", Toast.LENGTH_LONG).show();
btnStatusMessage.setText(hours+" hr "+minutes+" min ");
}