android - Android 中的 JobService 是什么

标签 android android-service android-5.0-lollipop jobservice

我正在检查 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/

相关文章:

android - 我的应用程序出现蓝牙问题

java - 使用 AppCompatActivity 时出现 NoClassDefFoundError

android - 通知服务在通知点击上增加了额外的费用,怎么样?

android - 在 init.rc 中禁用 android 服务

Android Studio 不让我安装 Android SDK 平台

android - Android SDK更新后新项目创建问题

Android进程在杀死应用程序时出现错误

android - 作业调度程序 API android L

Android Lollipop 更改导航栏颜色

android - Android应用中TypedArray的使用