0

I have a Handler and a runnable to be done in 3000ms when I touch the screen.

How can I display the time left to happen since I touched the screen?

Is there any way to display it on a textview or something alike?

Newd
  • 2,174
  • 2
  • 17
  • 31
Deldri
  • 37
  • 4
  • I don't think the Handler itself has any kind of `getTimeUntil()` type method that will tell you. So you'd have to keep track of the time separately yourself in order to display it back to the user. – FoamyGuy Jul 06 '15 at 18:16
  • Why not use asynctask. It has onprogressupdate method which allows you to post progress. Yes you can use a textview . – Ramandeep Nanda Jul 06 '15 at 18:17
  • Thanks both, i will look for info of asynctask. – Deldri Jul 06 '15 at 18:44

1 Answers1

0

Easiest way is to add a counter value and increase it by 1000. Then rather using postDelayed(3000) you can use postDelayed(1000).

Every time the runnable is called, increase the counter with 1000 until it became the expected value (3000 in this case). Then do you work and return.

Dimitar Genov
  • 2,056
  • 13
  • 11