public class Timer extends Object
Stopwatch| Modifier and Type | Class and Description | 
|---|---|
static interface  | 
Timer.OnTickListener
Listener interface to listen for important clock events with the timer. 
 | 
| Constructor and Description | 
|---|
Timer()
The default constructor used to create an instance of Timer. 
 | 
Timer(long duration)
Parameterized constructor used to initialize an instance of Timer with a specified duration 
 | 
| Modifier and Type | Method and Description | 
|---|---|
long | 
getDuration()
Fetch the set duration of the timer 
 | 
long | 
getRemainingTime()
Get the remaining time of the timer in milliseconds 
 | 
long | 
getStart()
Get the start time in long 
 | 
boolean | 
isPaused()
Returns true if the timer is paused 
 | 
boolean | 
isStarted()
Returns true if the timer has been started 
 | 
void | 
pause()
Used to pause the timer. 
 | 
void | 
resume()
Used to resume a paused timer. 
 | 
void | 
setDuration(long duration)
Used to set the duration of the timer. 
 | 
void | 
setOnTickListener(Timer.OnTickListener onTickListener)
Used to set an OnTickListener to listen to clock events 
 | 
void | 
setTextView(TextView textView)
Used to set the textView which is auto-updated every clock tick. 
 | 
void | 
start()
Used to start the timer. 
 | 
void | 
stop()
Used to stop the timer. 
 | 
public Timer()
Timer(long), 
setDuration(long)public Timer(long duration)
duration - the duration for which the timer should run in millisecondsTimer()public boolean isStarted()
public boolean isPaused()
public long getRemainingTime()
public long getStart()
public long getDuration()
public void setDuration(long duration)
duration - the duration in milliseconds for which you want to set the timerpublic void setTextView(@Nullable
                        TextView textView)
textView - the textView to update every clock tick.public void setOnTickListener(Timer.OnTickListener onTickListener)
onTickListener - an instance of Timer.OnTickListenerTimer.OnTickListenerpublic void start()
public void stop()
public void pause()
public void resume()