定时器每5秒触发一次

时间:2012-04-01 16:25:13

标签: android

我怎样才能连续每5秒运行一次计时器。 下面是代码片段::

Timer timer;
TimerTask timerTask  = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
    Log.d("adad","asdadsa");
}
};
timer.schedule(timerTask,0,5);

1 个答案:

答案 0 :(得分:0)

Timer timer= new Timer();
TimerTask timerTask = new TimerTask() {
  @Override
  public void run() {
    // TODO Auto-generated method stub
    Log.d("adad","asdadsa");
  }
};
timer.schedule(timerTask,0,5000);

一些小的改动检查它......