public class JobSchedulerImpl extends JobScheduler
RESULT_FAILURE, RESULT_SUCCESS
Modifier and Type | Method and Description |
---|---|
void |
cancel(int jobId)
Cancel a job that is pending in the JobScheduler.
|
void |
cancelAll()
Cancel all jobs that have been registered with the JobScheduler by this package.
|
List<JobInfo> |
getAllPendingJobs()
Retrieve all jobs for this package that are pending in the JobScheduler.
|
JobInfo |
getPendingJob(int jobId)
Retrieve a specific job for this package that is pending in the
JobScheduler.
|
int |
schedule(JobInfo job) |
int |
scheduleAsPackage(JobInfo job,
String packageName,
int userId,
String tag) |
public int schedule(JobInfo job)
schedule
in class JobScheduler
job
- The job you wish scheduled. See
JobInfo.Builder
for more detail on the sorts of jobs
you can schedule.JobScheduler.RESULT_SUCCESS
or JobScheduler.RESULT_FAILURE
).public int scheduleAsPackage(JobInfo job, String packageName, int userId, String tag)
scheduleAsPackage
in class JobScheduler
job
- The job to be scheduled.packageName
- The package on behalf of which the job is to be scheduled. This will be
used to track battery usage and appIdleState.userId
- User on behalf of whom this job is to be scheduled.tag
- Debugging tag for dumps associated with this job (instead of the service class)JobScheduler.RESULT_SUCCESS
or JobScheduler.RESULT_FAILURE
public void cancel(int jobId)
JobScheduler
cancel
in class JobScheduler
jobId
- unique identifier for this job. Obtain this value from the jobs returned by
JobScheduler.getAllPendingJobs()
.public void cancelAll()
JobScheduler
cancelAll
in class JobScheduler
public List<JobInfo> getAllPendingJobs()
JobScheduler
getAllPendingJobs
in class JobScheduler
public JobInfo getPendingJob(int jobId)
JobScheduler
getPendingJob
in class JobScheduler