Android Touch Event determining duration

前端 未结 3 1823
無奈伤痛
無奈伤痛 2020-12-03 08:47

How does one detect the duration of an Android 2.1 touch event? I would like to respond only if the region has been pressed for say 5 seconds?

3条回答
  •  既然无缘
    2020-12-03 09:15

    You can't use unix timestamps in this case. Android offers it's own time measurement.

    long eventDuration = 
                android.os.SystemClock.elapsedRealtime() 
                - event.getDownTime();
    

提交回复
热议问题