FileDocCategorySizeDatePackage
JobInfo.javaAPI DocAndroid 5.1 API18364Thu Mar 12 22:22:10 GMT 2015android.app.job

JobInfo

public class JobInfo extends Object implements android.os.Parcelable
Container of data passed to the {@link android.app.job.JobScheduler} fully encapsulating the parameters required to schedule work against the calling application. These are constructed using the {@link JobInfo.Builder}. You must specify at least one sort of constraint on the JobInfo object that you are creating. The goal here is to provide the scheduler with high-level semantics about the work you want to accomplish. Doing otherwise with throw an exception in your app.

Fields Summary
public static final int
NETWORK_TYPE_NONE
Default.
public static final int
NETWORK_TYPE_ANY
This job requires network connectivity.
public static final int
NETWORK_TYPE_UNMETERED
This job requires network connectivity that is unmetered.
public static final long
DEFAULT_INITIAL_BACKOFF_MILLIS
Amount of backoff a job has initially by default, in milliseconds.
public static final long
MAX_BACKOFF_DELAY_MILLIS
Maximum backoff we allow for a job, in milliseconds.
public static final int
BACKOFF_POLICY_LINEAR
Linearly back-off a failed job. See {@link android.app.job.JobInfo.Builder#setBackoffCriteria(long, int)} retry_time(current_time, num_failures) = current_time + initial_backoff_millis * num_failures, num_failures >= 1
public static final int
BACKOFF_POLICY_EXPONENTIAL
Exponentially back-off a failed job. See {@link android.app.job.JobInfo.Builder#setBackoffCriteria(long, int)} retry_time(current_time, num_failures) = current_time + initial_backoff_millis * 2 ^ (num_failures - 1), num_failures >= 1
public static final int
DEFAULT_BACKOFF_POLICY
Default type of backoff.
private final int
jobId
private final android.os.PersistableBundle
extras
private final android.content.ComponentName
service
private final boolean
requireCharging
private final boolean
requireDeviceIdle
private final boolean
hasEarlyConstraint
private final boolean
hasLateConstraint
private final int
networkType
private final long
minLatencyMillis
private final long
maxExecutionDelayMillis
private final boolean
isPeriodic
private final boolean
isPersisted
private final long
intervalMillis
private final long
initialBackoffMillis
private final int
backoffPolicy
public static final Creator
CREATOR
Constructors Summary
private JobInfo(android.os.Parcel in)

        jobId = in.readInt();
        extras = in.readPersistableBundle();
        service = in.readParcelable(null);
        requireCharging = in.readInt() == 1;
        requireDeviceIdle = in.readInt() == 1;
        networkType = in.readInt();
        minLatencyMillis = in.readLong();
        maxExecutionDelayMillis = in.readLong();
        isPeriodic = in.readInt() == 1;
        isPersisted = in.readInt() == 1;
        intervalMillis = in.readLong();
        initialBackoffMillis = in.readLong();
        backoffPolicy = in.readInt();
        hasEarlyConstraint = in.readInt() == 1;
        hasLateConstraint = in.readInt() == 1;
    
private JobInfo(Builder b)

        jobId = b.mJobId;
        extras = b.mExtras;
        service = b.mJobService;
        requireCharging = b.mRequiresCharging;
        requireDeviceIdle = b.mRequiresDeviceIdle;
        networkType = b.mNetworkType;
        minLatencyMillis = b.mMinLatencyMillis;
        maxExecutionDelayMillis = b.mMaxExecutionDelayMillis;
        isPeriodic = b.mIsPeriodic;
        isPersisted = b.mIsPersisted;
        intervalMillis = b.mIntervalMillis;
        initialBackoffMillis = b.mInitialBackoffMillis;
        backoffPolicy = b.mBackoffPolicy;
        hasEarlyConstraint = b.mHasEarlyConstraint;
        hasLateConstraint = b.mHasLateConstraint;
    
Methods Summary
public intdescribeContents()

        return 0;
    
public intgetBackoffPolicy()
One of either {@link android.app.job.JobInfo#BACKOFF_POLICY_EXPONENTIAL}, or {@link android.app.job.JobInfo#BACKOFF_POLICY_LINEAR}, depending on which criteria you set when creating this job.

        return backoffPolicy;
    
public android.os.PersistableBundlegetExtras()
Bundle of extras which are returned to your application at execution time.

        return extras;
    
public intgetId()
Unique job id associated with this class. This is assigned to your job by the scheduler.


                         
       
        return jobId;
    
public longgetInitialBackoffMillis()
The amount of time the JobScheduler will wait before rescheduling a failed job. This value will be increased depending on the backoff policy specified at job creation time. Defaults to 5 seconds.

        return initialBackoffMillis;
    
public longgetIntervalMillis()
Set to the interval between occurrences of this job. This value is not set if the job does not recur periodically.

        return intervalMillis;
    
public longgetMaxExecutionDelayMillis()
See {@link Builder#setOverrideDeadline(long)}. This value is not set if the job recurs periodically.

        return maxExecutionDelayMillis;
    
public longgetMinLatencyMillis()
Set for a job that does not recur periodically, to specify a delay after which the job will be eligible for execution. This value is not set if the job recurs periodically.

        return minLatencyMillis;
    
public intgetNetworkType()
One of {@link android.app.job.JobInfo#NETWORK_TYPE_ANY}, {@link android.app.job.JobInfo#NETWORK_TYPE_NONE}, or {@link android.app.job.JobInfo#NETWORK_TYPE_UNMETERED}.

        return networkType;
    
public android.content.ComponentNamegetService()
Name of the service endpoint that will be called back into by the JobScheduler.

        return service;
    
public booleanhasEarlyConstraint()
User can specify an early constraint of 0L, which is valid, so we keep track of whether the function was called at all.

hide

        return hasEarlyConstraint;
    
public booleanhasLateConstraint()
User can specify a late constraint of 0L, which is valid, so we keep track of whether the function was called at all.

hide

        return hasLateConstraint;
    
public booleanisPeriodic()
Track whether this job will repeat with a given period.

        return isPeriodic;
    
public booleanisPersisted()

return
Whether or not this job should be persisted across device reboots.

        return isPersisted;
    
public booleanisRequireCharging()
Whether this job needs the device to be plugged in.

        return requireCharging;
    
public booleanisRequireDeviceIdle()
Whether this job needs the device to be in an Idle maintenance window.

        return requireDeviceIdle;
    
public java.lang.StringtoString()


    
       
        return "(job:" + jobId + "/" + service.flattenToShortString() + ")";
    
public voidwriteToParcel(android.os.Parcel out, int flags)

        out.writeInt(jobId);
        out.writePersistableBundle(extras);
        out.writeParcelable(service, flags);
        out.writeInt(requireCharging ? 1 : 0);
        out.writeInt(requireDeviceIdle ? 1 : 0);
        out.writeInt(networkType);
        out.writeLong(minLatencyMillis);
        out.writeLong(maxExecutionDelayMillis);
        out.writeInt(isPeriodic ? 1 : 0);
        out.writeInt(isPersisted ? 1 : 0);
        out.writeLong(intervalMillis);
        out.writeLong(initialBackoffMillis);
        out.writeInt(backoffPolicy);
        out.writeInt(hasEarlyConstraint ? 1 : 0);
        out.writeInt(hasLateConstraint ? 1 : 0);