Android倒计时器——CountDownTimer
16lz
2021-12-04
Android倒计时器——CountDownTimer
说明
第一个参数是倒计时的时间
第二个参数是多长时间执行一次回调
/** * @param millisInFuture The number of millis in the future from the call to {@link #start()} until the countdown is done and {@link #onFinish()} is called. * @param countDownInterval The interval along the way to receive {@link #onTick(long)} callbacks. */public CountDownTimer(long millisInFuture, long countDownInterval)
初始化
CountDownTimer timer = new CountDownTimer(Long.MAX_VALUE, Constants.LOOP_TIME) { @Override public void onTick(long millisUntilFinished) { // 倒计时当中的回调 } @Override public void onFinish() { // 倒计时结束后的回调 } };
开始倒计时
timer.start();
停止倒计时
timer.cancel();
更多相关文章
- Android(安卓)P WMS初始化过程
- SystemUI9.0系统应用图标加载流程
- Android(安卓)中级教程(一)之------Android(安卓)MediaPlayer播
- Android(安卓)中级教程之------Android(安卓)MediaPlayer播放mp3
- Android(安卓)中级教程之------Android(安卓)MediaPlayer播放mp3
- android java代码的启动:app_process
- Android(安卓)中级教程之------Android(安卓)MediaPlayer播放mp3
- android java代码的启动:app_process
- Android百度地图导航的那些坑