I have a button on which I want to set the timer for 5 seconds for the first time and it should perform some task after completing 5 seconds. Also if user click button 2 times it should start timer for 10 seconds and after 10 seconds it should perform specific task. and if user click 3rd time it should stop all running timers. so I have do not know How to implement timer for one time what I have search is this. But in this link it is continuously repeating after specific period of time, whereas I want to run once.
Now what I want
- To start timer with first click (of 5 seconds)and if meanwhile user click 2nd time it should set timer with with new time period and if user click third time it cancels out all timers.
- I do not want to use Thread timer using sleep method.
- I want same behavior as there is in camera app in android 5.0 v.
So please tell me how to do this any code and source code would be appreciated.