Class WorkManagerScheduler

    • Method Detail

      • schedule

        public boolean schedule​(Requirements requirements,
                                String servicePackage,
                                String serviceAction)
        Description copied from interface: Scheduler
        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 Service.startForeground(int, Notification) to make itself a foreground service, as documented by ContextWrapper.startForegroundService(Intent).

        Specified by:
        schedule in interface Scheduler
        Parameters:
        requirements - The requirements.
        servicePackage - The package name.
        serviceAction - The action with which the service will be started.
        Returns:
        Whether scheduling was successful.
      • cancel

        public boolean cancel()
        Description copied from interface: Scheduler
        Cancels anything that was previously scheduled, or else does nothing.
        Specified by:
        cancel in interface Scheduler
        Returns:
        Whether cancellation was successful.
      • getSupportedRequirements

        public Requirements getSupportedRequirements​(Requirements requirements)
        Description copied from interface: Scheduler
        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.
        Specified by:
        getSupportedRequirements in interface Scheduler
        Parameters:
        requirements - The requirements to check.
        Returns:
        The supported requirements.