我正在检查 Android-L 开发者 SDK 中的最新示例。 android-L/ui/views/Clipping/ClippingBasic
中有一个名为 TestJobService 的示例类。它从 JobService 延伸,它又从 Service 扩展而来。我看到 JobService 是 android.jar 中的一个类,但我在开发指南和 Android 源代码中都找不到关于它的任何信息 www.androidxref.com .有没有人见过这个类或知道它的目的是什么?
最佳答案
这是一种新型服务,根据系统条件(例如空闲、插入)为计划运行的任务调用。
Entry point for the callback from the JobScheduler.
This is the base class that handles asynchronous requests that were previously scheduled. You are responsible for overriding
onStartJob(JobParameters)
, which is where you will implement your job logic.
您基本上创建了一个描述这些条件的 JobInfo
对象(使用 JobInfo.Builder
)并设置必须执行的服务的组件名称。
要安排它们,您需要 JobScheduler
,您可以使用 Context.getSystemService(Context.JOB_SCHEDULER_SERVICE)
访问它。
顺便说一下,L Preview Documentation is here ,以防你不知道。
更新: 这是关于 JobService 的文档: https://developer.android.com/reference/android/app/job/JobService.html
关于android - Android 中的 JobService 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24613494/