Timer timer = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { try { Log.i("feng", "定时器" +(i++)); } catch (Exception e) { e.printStackTrace(); } } };
/** * task:要启动的定时器 * 0:等待时间 * 1000:间隔时间 * */ timer.schedule(task,0,1000);