PlatformScheduler
@UnstableApi
public final class PlatformScheduler implements Scheduler
A Scheduler that uses JobScheduler. To use this scheduler, you must add PlatformSchedulerService to your manifest:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <service android:name="androidx.media3.exoplayer.scheduler.PlatformScheduler$PlatformSchedulerService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true"/>
Summary
Nested types |
|---|
public final class PlatformScheduler.PlatformSchedulerService extends JobServiceA |
Public constructors |
|---|
@RequiresPermission(value = android.Manifest.permission.RECEIVE_BOOT_COMPLETED) |
Public methods |
|
|---|---|
boolean |
cancel()Cancels anything that was previously scheduled, or else does nothing. |
Requirements |
getSupportedRequirements(Requirements requirements)Checks whether this |
boolean |
schedule(Schedules a service to be started in the foreground when some |
Public constructors
PlatformScheduler
@RequiresPermission(value = android.Manifest.permission.RECEIVE_BOOT_COMPLETED)
public PlatformScheduler(Context context, int jobId)
Public methods
cancel
public boolean cancel()
Cancels anything that was previously scheduled, or else does nothing.
| Returns | |
|---|---|
boolean |
Whether cancellation was successful. |
getSupportedRequirements
public Requirements getSupportedRequirements(Requirements requirements)
Checks whether this Scheduler supports the provided Requirements. If all of the requirements are supported then the same Requirements instance is returned. If not then a new instance is returned containing the subset of the requirements that are supported.
| Parameters | |
|---|---|
Requirements requirements |
The requirements to check. |
| Returns | |
|---|---|
Requirements |
The supported requirements. |
schedule
public boolean schedule(
Requirements requirements,
String servicePackage,
String serviceAction
)
Schedules a service to be started in the foreground when some 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 startForeground to make itself a foreground service, as documented by startForegroundService.
| Parameters | |
|---|---|
Requirements requirements |
The requirements. |
String servicePackage |
The package name. |
String serviceAction |
The action with which the service will be started. |
| Returns | |
|---|---|
boolean |
Whether scheduling was successful. |