public abstract class JobScheduler
extends Object
| java.lang.Object | |
| android.app.job.JobScheduler | |
这是一个API,用于根据将在应用程序自己的进程中执行的框架调度各种类型的作业。
有关可以运行的作业类型以及如何构建它们的更多描述,请参见JobInfo 。 您将构造这些JobInfo对象,并将它们传递给JobScheduler,其中包含schedule(JobInfo) 。 当满足声明的标准时,系统将在您的应用程序的JobService上执行此作业。 当您使用JobInfo.Builder(int, android.content.ComponentName)创建JobInfo时,您可以确定哪个JobService用于执行作业的逻辑。
当你收到你的回调时,这个框架将是明智的,并且尽可能地尝试批量和推迟它们。 通常情况下,如果您没有在作业中指定截止日期,则可以随时运行,具体取决于JobScheduler内部队列的当前状态,但只要直到下次设备连接到电源时才会延迟资源。
你不直接实例化这个类; 相反,通过Context.getSystemService(Context.JOB_SCHEDULER_SERVICE)检索它。
常量(Constants) |
|
|---|---|
int |
RESULT_FAILURE 当提供无效参数时从 |
int |
RESULT_SUCCESS 如果此作业已成功安排,则从 |
Public constructors |
|
|---|---|
JobScheduler() |
|
公共方法(Public methods) |
|
|---|---|
abstract void |
cancel(int jobId) 取消JobScheduler中待处理的作业。 |
abstract void |
cancelAll() 通过此包取消所有已通过JobScheduler注册的作业。 |
abstract List<JobInfo> |
getAllPendingJobs() 检索JobScheduler中待处理的此包的所有作业。 |
abstract JobInfo |
getPendingJob(int jobId) 为JobScheduler中待处理的此包检索特定作业。 |
abstract int |
schedule(JobInfo job) |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
int RESULT_FAILURE
当提供无效参数时从schedule(JobInfo)返回。 如果作业的运行时间太短,或者系统无法解析软件包中必需的JobService ,则会发生这种情况。
常量值:0(0x00000000)
int RESULT_SUCCESS
如果此作业已成功安排,则从 schedule(JobInfo)返回。
常数值:1(0x00000001)
void cancel (int jobId)
取消JobScheduler中待处理的作业。
| 参数(Parameters) | |
|---|---|
jobId |
int: unique identifier for this job. Obtain this value from the jobs returned by getAllPendingJobs(). |
List<JobInfo> getAllPendingJobs ()
检索JobScheduler中待处理的此包的所有作业。
| 返回(Returns) | |
|---|---|
List<JobInfo> |
a list of all the jobs registered by this package that have not yet been executed. |
JobInfo getPendingJob (int jobId)
为JobScheduler中待处理的此包检索特定作业。
| 参数(Parameters) | |
|---|---|
jobId |
int
|
| 返回(Returns) | |
|---|---|
JobInfo |
job registered by this package that has not yet been executed. |
int schedule (JobInfo job)
| 参数(Parameters) | |
|---|---|
job |
JobInfo: The job you wish scheduled. See JobInfo.Builder for more detail on the sorts of jobs you can schedule. |
| 返回(Returns) | |
|---|---|
int |
An int representing (RESULT_SUCCESS or RESULT_FAILURE). |