타이머
-
[Android] CountDownTime 주기적 실행 타이머Android 2020. 6. 16. 17:01
CountDownTimer countDownTimer = new CountDownTimer(10 * 1000, 1000) { public void onTick(long millisUntilFinished) { //반복 실행 구문 } public void onFinish() { //마지막 실행 구문 } }; countDownTimer.start(); //타이머 실행 countDownTimer.cancel(); //타이머 종료 CountDownTimer 의 객체를 생성할때 매개변수 2개 = 총 실행될 시간, 반복주기시간 단위는 모두 ms 단위이므로 위 구문에서는 '10초(10*1000 ms) 동안 1초(1000 ms)마다 실행하겠다' 라는 뜻 CountDownTimer 의 객체를 생성하면 자동으로 onTic..