public final class PlatformScheduler extends java.lang.Object implements Scheduler
Scheduler that uses JobScheduler. To use this scheduler, you must add PlatformScheduler.PlatformSchedulerService to your manifest:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<service android:name="com.google.android.exoplayer2.util.scheduler.PlatformScheduler$PlatformSchedulerService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true"/>
| Modifier and Type | Class and Description |
|---|---|
static class |
PlatformScheduler.PlatformSchedulerService
A
JobService that starts the target service if the requirements are met. |
| Constructor and Description |
|---|
PlatformScheduler(android.content.Context context,
int jobId) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel()
Cancels anything that was previously scheduled, or else does nothing.
|
boolean |
schedule(Requirements requirements,
java.lang.String servicePackage,
java.lang.String serviceAction)
Schedules a service to be started in the foreground when some
Requirements are met. |
public PlatformScheduler(android.content.Context context,
int jobId)
context - Any context.jobId - An identifier for the jobs scheduled by this instance. If the same identifier was
used by a previous instance, anything scheduled by the previous instance will be canceled
by this instance if schedule(Requirements, String, String) or cancel()
are called.public boolean schedule(Requirements requirements, java.lang.String servicePackage, java.lang.String serviceAction)
SchedulerRequirements 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 Service.startForeground(int, Notification) to
make itself a foreground service, as documented by ContextWrapper.startForegroundService(Intent).