| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static Timer.RepeatTimer |
getTimer(Context context,
Timer.TimerIntent operation) |
Obtains a repeating timer.
|
void |
start(int type,
long triggerTime,
long interval) |
Starts a repeating timer with a fixed interval.
|
void |
stop() |
Cancels the timer.
|
public static Timer.RepeatTimer getTimer(Context context, Timer.TimerIntent operation)
This method uses the returned timer object to set and start a timer. When the timer goes off, the system sends an intent to start a component.
context - Indicates the application context.operation - Indicates the intent to send when the timer goes off.RepeatTimer instance that is created using the operation as the key.public void start(int type,
long triggerTime,
long interval)
When the timer goes off, the system sends an intent to start a component.
type - Indicates the timer type.triggerTime - Indicates the time at which the timer is triggered for the first time, in milliseconds.
The time will be automatically set to 5000 milliseconds after the current time if the passed value
is smaller than the current time plus 5000 milliseconds.interval - Indicates the interval between two consecutive triggers, in milliseconds.
The interval will be set to 5000 milliseconds automatically if the passed value is smaller than 5000.Timer.TIMER_TYPE_REALTIME,
Timer.TIMER_TYPE_WAKEUP,
Timer.TIMER_TYPE_EXACTpublic void stop()
Note: This method will cancel all the timers.