| 构造器 | 说明 |
|---|---|
Builder() |
Instantiates a new Builder.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
WorkInfo |
build() |
Constructs the
WorkInfo object based on the configured elements and triggering conditions. |
WorkInfo.Builder |
requestBatteryStatus(int requestStatus) |
Creates a
WorkInfo object that sets the battery state for triggering a work. |
WorkInfo.Builder |
requestChargingType(boolean requestCharging,
int requestchargerType) |
Creates a
WorkInfo object that sets the charger type for triggering a work. |
WorkInfo.Builder |
requestDeviceIdleType(boolean needDeepIdle,
int idleWaitTime) |
Creates a
WorkInfo object that sets the device deep idle status for triggering a work. |
WorkInfo.Builder |
requestNetworkType(int networkType) |
Creates a
WorkInfo object that sets the network type for triggering a work. |
WorkInfo.Builder |
requestPersisted(boolean requestPersisted) |
Creates a
WorkInfo object that sets whether the current work will be saved. |
WorkInfo.Builder |
requestRepeatCycle(long cycleTime) |
Creates a
WorkInfo object that sets the interval for repeating a work for unlimited times. |
WorkInfo.Builder |
requestRepeatCycle(long cycleTime,
int requestRepeatTimes) |
Creates a
WorkInfo object that sets the interval for repeating a work with limited times. |
WorkInfo.Builder |
requestStorageStatus(int requestStatus) |
Creates a
WorkInfo object that sets the storage state for triggering a work. |
WorkInfo.Builder |
setAbilityInfo(int id,
String bundleName,
String className) |
Creates a
WorkInfo object that sets the Particle Ability to start when a work is triggered. |
WorkInfo.Builder |
setPacMaps(PacMap maps) |
Sets extra parameters for this piece of work.
|
public WorkInfo build()
WorkInfo object based on the configured elements and triggering conditions.
After setting the related elements and triggering conditions, you must call this method to create
the WorkInfo object.
WorkInfo object created based on the configured elements and triggering conditions.public WorkInfo.Builder setAbilityInfo(int id, String bundleName, String className)
WorkInfo object that sets the Particle Ability to start when a work is triggered.
This method must be called to add ElementNam of the Particle Ability to (@code WorkInfo}.
Otherwise, a failure occurs when calling methods such as WorkScheduler#startWork.
id - Specifies the work ID. If a work with the same ID already exists, it will be replaced by the
new work.bundleName - Specifies the bundlename.className - Specifies the class to start when the work is triggered.WorkInfo object that sets the Particle Ability to start when a work is triggered.public WorkInfo.Builder requestNetworkType(int networkType)
WorkInfo object that sets the network type for triggering a work.
Call this method only when a work needs to be triggered based on the network type. If there are multiple types of networks, call this method to set one network type at a time.
networkType - Specifies the network type, which can be WorkInfo.NETWORK_TYPE_MOBILE or
WorkInfo.NETWORK_TYPE_WIFI.WorkInfo object that sets the network type for triggering a work.public WorkInfo.Builder requestDeviceIdleType(boolean needDeepIdle, int idleWaitTime)
WorkInfo object that sets the device deep idle status for triggering a work.
You can call this method to set or cancel the device deep idle status. A device is considered deep idle
if all the following conditions are true: The device screen is off, the device is not in the sleep state,
and no user-aware work is running.
By default, the device deep idle status is set as the triggering condition of a work. If any other triggering
condition except requestPersisted(boolean) is set, the work will not be triggered when the device enters
the deep idle state.
needDeepIdle - Specifies whether a work is triggered when the device enters the deep idle state.idleWaitTime - Specifies the wait time before a work is triggered when the device enters the deep idle
state. The time range is specified by WorkInfo.MIN_IDLE_WAIT_TIME_MS and
WorkInfo.MAX_IDLE_WAIT_TIME_MS.WorkInfo object that sets the device deep idle status for triggering a work.public WorkInfo.Builder requestChargingType(boolean requestCharging, int requestchargerType)
WorkInfo object that sets the charger type for triggering a work.
Call this method only when a work needs to be triggered based on the charger type. If there are multiple types of chargers, call this method to set one charger at a time.
requestCharging - Specifies whether a work is triggered when the device starts charging.requestchargerType - Specifies the charger type.WorkInfo object that sets the charger type for triggering a work.public WorkInfo.Builder requestBatteryStatus(int requestStatus)
WorkInfo object that sets the battery state for triggering a work.
Call this method only when a work needs to be triggered based on the battery state. Note that only one battery state can be specified.
requestStatus - Specifies the battery state, which can be WorkInfo.BATTERY_LEVEL_LOW,
WorkInfo.BATTERY_LEVEL_OKAY, or WorkInfo.BATTERY_LEVEL_LOW_OR_OKAY.WorkInfo object that sets the charger type for triggering a work.public WorkInfo.Builder requestStorageStatus(int requestStatus)
WorkInfo object that sets the storage state for triggering a work.
Call this method only when a work needs to be triggered based on the storage state. Note that only one storage state can be specified.
requestStatus - Specifies the storage state, which can be WorkInfo.STORAGE_LEVEL_LOW,
WorkInfo.STORAGE_LEVEL_OKAY, or WorkInfo.STORAGE_LEVEL_LOW_OR_OKAY.WorkInfo object that sets the storage state for triggering a work.public WorkInfo.Builder requestRepeatCycle(long cycleTime)
WorkInfo object that sets the interval for repeating a work for unlimited times.
Call this method only when a work needs to repeat at the specified interval. Note the following:
1. After the device enters the sleep state, the work does not take effect.
2. When the device is not in sleep state, for example, the device screen is on and the application
which is not the father who set the work in the foreground, the work is not triggered even if the
specified interval is reached. If the device enters the light idle state, the work will be triggered
immediately. If the device does not enter the idle state when the time specified by
WorkInfo.MAX_REPEAT_DELAY_TIME_MS is reached, then the work will be forcibly triggered.
3. If another triggering condition, for example, charger, is also set, the work will be triggered only once
even if the triggering condition is met multiple times during each interval.
cycleTime - Indicates the interval for triggering a work, in ms. The minimum value is
WorkInfo.MIN_REPEAT_CYCLE_TIME_MS.WorkInfo object that sets the interval for repeating a work without limited times.public WorkInfo.Builder requestRepeatCycle(long cycleTime, int requestRepeatTimes)
WorkInfo object that sets the interval for repeating a work with limited times.
Call this method only when a work needs to repeat at the specified interval. For details, see
requestRepeatCycle(long).
cycleTime - Indicates the interval for triggering a work, in ms. The minimum value
is WorkInfo.MIN_REPEAT_CYCLE_TIME_MS.requestRepeatTimes - Specifies the number of times for repeating a work.WorkInfo object that sets the interval for repeating a work with limited times.public WorkInfo.Builder requestPersisted(boolean requestPersisted)
WorkInfo object that sets whether the current work will be saved.
Call this method only when a work needs to be saved. By default, the save function is disabled when a
work is created; that is, the work will become invalid after the device is restarted. If you enable the
save function, the WorkScheduler will restore the work from the saved data
when the device is restarted.
requestPersisted - Specifies whether a work will be saved. Set the parameter to true if you
want to save the work; set the parameter to false otherwise.WorkInfo object that sets the Particle Ability to start when a work is triggered.public WorkInfo.Builder setPacMaps(PacMap maps)
maps - Indicates the PacMap object containing the extra parameters to set.Builder instance with the specified PacMap object.WorkInfo.getPacMaps()