# Scheduler

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/scheduler/Scheduler.java+class:androidx.media3.exoplayer.scheduler.Scheduler)

*** ** * ** ***


```
@UnstableApi
public interface Scheduler
```

<br />

Known direct subclasses [PlatformScheduler](https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/PlatformScheduler), [WorkManagerScheduler](https://developer.android.com/reference/androidx/media3/exoplayer/workmanager/WorkManagerScheduler)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/PlatformScheduler` | A `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Scheduler` that uses `https://developer.android.com/reference/android/app/job/JobScheduler.html`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/workmanager/WorkManagerScheduler` | A `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Scheduler` that uses `https://developer.android.com/reference/androidx/work/WorkManager`. |

*** ** * ** ***

Schedules a service to be started in the foreground when some `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements` are met.

## Summary

| ### Public methods |
|---|---|
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Scheduler#cancel()()` Cancels anything that was previously scheduled, or else does nothing. |
| `abstract https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements` | `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Scheduler#getSupportedRequirements(androidx.media3.exoplayer.scheduler.Requirements)(https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements requirements)` Checks whether this `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Scheduler` supports the provided `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements`. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Scheduler#schedule(androidx.media3.exoplayer.scheduler.Requirements,java.lang.String,java.lang.String)( https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements requirements, https://developer.android.com/reference/java/lang/String.html servicePackage, https://developer.android.com/reference/java/lang/String.html serviceAction )` Schedules a service to be started in the foreground when some `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements` are met. |

## Public methods

### cancel

```
abstract boolean cancel()
```

Cancels anything that was previously scheduled, or else does nothing.

| Returns |
|---|---|
| `boolean` | Whether cancellation was successful. |

### getSupportedRequirements

```
abstract Requirements getSupportedRequirements(Requirements requirements)
```

Checks whether this `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Scheduler` supports the provided `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements`. If all of the requirements are supported then the same `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements` instance is returned. If not then a new instance is returned containing the subset of the requirements that are supported.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements requirements` | The requirements to check. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements` | The supported requirements. |

### schedule

```
abstract boolean schedule(
    Requirements requirements,
    String servicePackage,
    String serviceAction
)
```

Schedules a service to be started in the foreground when some `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements` are met. Anything that was previously scheduled will be canceled.

The service to be started must be declared in the manifest of `servicePackage` with an intent filter containing `serviceAction`. Note that when started with `
serviceAction`, the service must call `https://developer.android.com/reference/android/app/Service.html#startForeground(int, android.app.Notification)` to make itself a foreground service, as documented by `https://developer.android.com/reference/android/content/ContextWrapper.html#startForegroundService(android.content.Intent)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements requirements` | The requirements. |
| `https://developer.android.com/reference/java/lang/String.html servicePackage` | The package name. |
| `https://developer.android.com/reference/java/lang/String.html serviceAction` | The action with which the service will be started. |

| Returns |
|---|---|
| `boolean` | Whether scheduling was successful. |