Android - To measure the time between the two button clicks

后端 未结 3 1478
南旧
南旧 2021-01-01 18:08

I have a button named Check In. My aim is on click to change the text and start counting the time. The timer has to stop at the next click. It should give the t

3条回答
  •  心在旅途
    2021-01-01 18:38

    I think it is better practice to use System.nanoTime() instead of System.currentTimeMillis(), as currentTimeMillis() relies on what time the system's clock is set to, which can be changed.

    nanoTime(), however, is really designed to measure elapsed time according to the JavaDoc.

提交回复
热议问题