public final class JobRequest
extends java.lang.Object
Job. Use the JobRequest.Builder to create an instance.
Once built you can either call schedule() or JobManager.schedule(JobRequest)
to schedule the request.| Modifier and Type | Class and Description |
|---|---|
static class |
JobRequest.BackoffPolicy |
static class |
JobRequest.Builder
Builder class for constructing JobRequests.
|
static class |
JobRequest.NetworkType |
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_BACKOFF_MS
If you don't change the back-off ms, then 30 seconds are used as default.
|
static JobRequest.BackoffPolicy |
DEFAULT_BACKOFF_POLICY
If you don't change the back-off policy, then EXPONENTIAL is used as default.
|
static JobRequest.NetworkType |
DEFAULT_NETWORK_TYPE
If you don't change the required network type, then no connection is required.
|
static long |
MIN_FLEX
The minimum flex of a periodic job.
|
static long |
MIN_INTERVAL
The minimum interval of a periodic job.
|
| Modifier and Type | Method and Description |
|---|---|
JobRequest.Builder |
cancelAndEdit()
Cancel this request if it has been scheduled.
|
boolean |
equals(java.lang.Object o) |
long |
getBackoffMs()
Only valid if the job isn't periodic.
|
JobRequest.BackoffPolicy |
getBackoffPolicy()
Only valid if the job isn't periodic.
|
long |
getEndMs()
Only valid if the job isn't periodic.
|
PersistableBundleCompat |
getExtras() |
long |
getFlexMs()
Flex time for this job.
|
long |
getIntervalMs()
Only valid if the job is periodic.
|
int |
getJobId() |
long |
getScheduledAt()
Returns the time when this job was scheduled.
|
long |
getStartMs()
Only valid if the job isn't periodic.
|
java.lang.String |
getTag() |
int |
hashCode() |
boolean |
isExact() |
boolean |
isPeriodic() |
boolean |
isPersisted() |
boolean |
isUpdateCurrent() |
JobRequest.NetworkType |
requiredNetworkType() |
boolean |
requirementsEnforced() |
boolean |
requiresCharging() |
boolean |
requiresDeviceIdle() |
int |
schedule()
Convenience method.
|
java.lang.String |
toString() |
public static final long DEFAULT_BACKOFF_MS
Builder#setBackoffCriteria(long, BackoffPolicy),
Constant Field Valuespublic static final JobRequest.BackoffPolicy DEFAULT_BACKOFF_POLICY
Builder#setBackoffCriteria(long, BackoffPolicy)public static final JobRequest.NetworkType DEFAULT_NETWORK_TYPE
Builder#setRequiredNetworkType(NetworkType),
JobRequest.Builder.setRequirementsEnforced(boolean)public static final long MIN_INTERVAL
JobScheduler starting with Android Nougat. You can read
here more about
the limit.public static final long MIN_FLEX
JobScheduler starting with Android Nougat. You can read
here more about
the limit.public int getJobId()
public java.lang.String getTag()
Job.public long getStartMs()
public long getEndMs()
public JobRequest.BackoffPolicy getBackoffPolicy()
public long getBackoffMs()
getBackoffPolicy()
if the job fails multiple times.public boolean isPeriodic()
public long getIntervalMs()
public long getFlexMs()
public boolean requirementsEnforced()
true, then all requirements are checked before the job runs. If one requirement
isn't met, then the job is rescheduled right away.public boolean requiresCharging()
true, then the job should only run if the device is charging.public boolean requiresDeviceIdle()
true, then job should only run if the device is idle.public JobRequest.NetworkType requiredNetworkType()
public PersistableBundleCompat getExtras()
public boolean isPersisted()
true, then the job persists across reboots.public boolean isUpdateCurrent()
true, then this request will overwrite any preexisting jobs.public boolean isExact()
true, then the job will run at exact time ignoring the device state.public long getScheduledAt()
public int schedule()
JobManager.schedule(JobRequest)
and getJobId() for this request.public JobRequest.Builder cancelAndEdit()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object