Countdown timer with pause and resume

后端 未结 8 903
小蘑菇
小蘑菇 2021-01-05 04:17

I want to do countdown timer with pause and restart.Now i am displaying countdown timer By implenting ontick() and onfinish().please help me out.HEre is th code for countdow

8条回答
  •  迷失自我
    2021-01-05 04:40

    I would add something to the onTick handler to save the progress of the timer in your class (number of milliseconds left).

    In the onPause() method for the activity call cancel() on the timer.

    In the onResume() method for the activity create a new timer with the saved number of milliseconds left.

    Refer the below links

    LINK

    LINK

提交回复
热议问题