Constraints.Builder
public
static
final
class
Constraints.Builder
extends Object
java.lang.Object
|
↳ |
androidx.work.Constraints.Builder
|
A Builder for a Constraints
object.
Summary
Inherited methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public constructors
Builder
public Builder ()
Public methods
addContentUriTrigger
public Constraints.Builder addContentUriTrigger (Uri uri,
boolean triggerForDescendants)
Sets whether the WorkRequest
should run when a local content:
Uri
is updated. This functionality is identical to the one found in JobScheduler
and
is described in
JobInfo.Builder#addTriggerContentUri(android.app.job.JobInfo.TriggerContentUri)
.
Parameters |
uri |
Uri : The local content: Uri to observe |
triggerForDescendants |
boolean : true if any changes in descendants cause this
WorkRequest to run |
setRequiresBatteryNotLow
public Constraints.Builder setRequiresBatteryNotLow (boolean requiresBatteryNotLow)
Sets whether device battery should be at an acceptable level for the
WorkRequest
to run. The default value is false
.
Parameters |
requiresBatteryNotLow |
boolean : true if the battery should be at an acceptable level
for the work to run |
setRequiresCharging
public Constraints.Builder setRequiresCharging (boolean requiresCharging)
Sets whether device should be charging for the WorkRequest
to run. The
default value is false
.
Parameters |
requiresCharging |
boolean : true if device must be charging for the work to run |
setRequiresDeviceIdle
public Constraints.Builder setRequiresDeviceIdle (boolean requiresDeviceIdle)
Sets whether device should be idle for the WorkRequest
to run. The default
value is false
.
Parameters |
requiresDeviceIdle |
boolean : true if device must be idle for the work to run |
setRequiresStorageNotLow
public Constraints.Builder setRequiresStorageNotLow (boolean requiresStorageNotLow)
Sets whether the device's available storage should be at an acceptable level for the
WorkRequest
to run. The default value is false
.
Parameters |
requiresStorageNotLow |
boolean : true if the available storage should not be below a
a critical threshold for the work to run |
setTriggerContentMaxDelay
public Constraints.Builder setTriggerContentMaxDelay (Duration duration)
Sets the maximum delay that is allowed from the first time a content:
Uri
change is detected to the time when the WorkRequest
is scheduled. This
functionality is identical to the one found in JobScheduler
and is described
in JobInfo.Builder#setTriggerContentMaxDelay(long)
.
Parameters |
duration |
Duration : The length of the delay |
setTriggerContentMaxDelay
public Constraints.Builder setTriggerContentMaxDelay (long duration,
TimeUnit timeUnit)
Sets the maximum delay that is allowed from the first time a content:
Uri
change is detected to the time when the WorkRequest
is scheduled.
This functionality is identical to the one found in JobScheduler
and
is described in JobInfo.Builder#setTriggerContentMaxDelay(long)
.
Parameters |
duration |
long : The length of the delay in timeUnit units |
timeUnit |
TimeUnit : The units of time for duration |
setTriggerContentUpdateDelay
public Constraints.Builder setTriggerContentUpdateDelay (long duration,
TimeUnit timeUnit)
Sets the delay that is allowed from the time a content:
Uri
change is detected to the time when the WorkRequest
is scheduled. If there are
more changes during this time, the delay will be reset to the start of the most recent
change. This functionality is identical to the one found in JobScheduler
and
is described in JobInfo.Builder#setTriggerContentUpdateDelay(long)
.
Parameters |
duration |
long : The length of the delay in timeUnit units |
timeUnit |
TimeUnit : The units of time for duration |
setTriggerContentUpdateDelay
public Constraints.Builder setTriggerContentUpdateDelay (Duration duration)
Sets the delay that is allowed from the time a content:
Uri
change
is detected to the time when the WorkRequest
is scheduled. If there are more
changes during this time, the delay will be reset to the start of the most recent change.
This functionality is identical to the one found in JobScheduler
and
is described in JobInfo.Builder#setTriggerContentUpdateDelay(long)
.
Parameters |
duration |
Duration : The length of the delay |