Interface Scheduler
-
- All Known Implementing Classes:
PlatformScheduler,WorkManagerScheduler
public interface SchedulerSchedules a service to be started in the foreground when someRequirementsare met.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancancel()Cancels anything that was previously scheduled, or else does nothing.RequirementsgetSupportedRequirements(Requirements requirements)Checks whether thisSchedulersupports the providedRequirements.booleanschedule(Requirements requirements, String servicePackage, String serviceAction)Schedules a service to be started in the foreground when someRequirementsare met.
-
-
-
Method Detail
-
schedule
boolean schedule(Requirements requirements, String servicePackage, String serviceAction)
Schedules a service to be started in the foreground when someRequirementsare met. Anything that was previously scheduled will be canceled.The service to be started must be declared in the manifest of
servicePackagewith an intent filter containingserviceAction. Note that when started withserviceAction, the service must callService.startForeground(int, Notification)to make itself a foreground service, as documented byContextWrapper.startForegroundService(Intent).- Parameters:
requirements- The requirements.servicePackage- The package name.serviceAction- The action with which the service will be started.- Returns:
- Whether scheduling was successful.
-
cancel
boolean cancel()
Cancels anything that was previously scheduled, or else does nothing.- Returns:
- Whether cancellation was successful.
-
getSupportedRequirements
Requirements getSupportedRequirements(Requirements requirements)
Checks whether thisSchedulersupports the providedRequirements. If all of the requirements are supported then the sameRequirementsinstance is returned. If not then a new instance is returned containing the subset of the requirements that are supported.- Parameters:
requirements- The requirements to check.- Returns:
- The supported requirements.
-
-