RunnableScheduler


interface RunnableScheduler


Can be used to schedule Runnables after a delay in milliseconds. This is used by the in-process scheduler to schedule timed work.

Summary

Public functions

Unit
cancel(runnable: Runnable)

Cancels the Runnable which was previously scheduled using scheduleWithDelay.

Unit
scheduleWithDelay(
    delayInMillis: @IntRange(from = 0) Long,
    runnable: Runnable
)

Schedules a Runnable to run after a delay (in milliseconds).

Public functions

cancel

Added in 2.4.0
fun cancel(runnable: Runnable): Unit

Cancels the Runnable which was previously scheduled using scheduleWithDelay.

Parameters
runnable: Runnable

The Runnable to be cancelled

scheduleWithDelay

Added in 2.4.0
fun scheduleWithDelay(
    delayInMillis: @IntRange(from = 0) Long,
    runnable: Runnable
): Unit

Schedules a Runnable to run after a delay (in milliseconds).

Parameters
delayInMillis: @IntRange(from = 0) Long

The delay in milliseconds relative to the current time.

runnable: Runnable

The Runnable to be scheduled

API reference packages and classes for Android app developers.

Updated Feb 10, 2025

Resources for reporting and resolving issues with the Android Gradle plugin.

Updated Apr 12, 2023

Android has many choices for guaranteed background work, which have various pros and cons. The WorkManager library for Android makes working in the background simple. WorkManager deals with edge cases and compatibility issues. It also can create tasks that are query-able, reusable and chain-able. WorkManager is the recommended task scheduler on Android. This codelab will teach you the ins-and-outs of WorkManager: everything from writing a simple job to more complex chained jobs with constraints.

Updated Sep 21, 2023