Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public abstract class

TimerTask

extends Object
implements Runnable
java.lang.Object
   ↳ java.util.TimerTask

Class Overview

The TimerTask class represents a task to run at a specified time. The task may be run once or repeatedly.

Summary

Protected Constructors
TimerTask ()
Creates a new TimerTask .
Public Methods
boolean cancel ()
Cancels the TimerTask and removes it from the Timer 's queue.
abstract void run ()
The task to run should be specified in the implementation of the run() method.
long scheduledExecutionTime ()
Returns the scheduled execution time.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Runnable

Protected Constructors

protected TimerTask ()

Added in API level 1

Creates a new TimerTask .

Public Methods

public boolean cancel ()

Added in API level 1

Cancels the TimerTask and removes it from the Timer 's queue. Generally, it returns false if the call did not prevent a TimerTask from running at least once. Subsequent calls have no effect.

Returns
  • true if the call prevented a scheduled execution from taking place, false otherwise.

public abstract void run ()

Added in API level 1

The task to run should be specified in the implementation of the run() method.

public long scheduledExecutionTime ()

Added in API level 1

Returns the scheduled execution time. If the task execution is in progress it returns the execution time of the ongoing task. Tasks which have not yet run return an undefined value.

Returns
  • the most recent execution time.