Android O 上的 JobScheduler 行为

JobScheduler behaviour on Android O

According to the documentation,从 Android 开始,O 服务将在应用程序不再位于前台几分钟后停止。

文档建议大多数服务可以替换为 JobScheduler 作业。我的问题是 - 作业是否也有任何类型的特殊行为,或者它们的行为是否与 Android O 之前的服务相同?它们可以存活 "forever"(当然,只要系统不需要内存),还是系统也会在某个 window 结束时杀死它们?

Can they live "forever" (as long as the system doesn't need the memory, of course), or do the system also kills them off at the end of a certain window?

没有。在我的测试中,您有大约 10 分钟的时间,而常规服务只有大约 1 分钟。

如果您需要一个永远运行的服务,您需要将其设为前台服务(startForegroundService() on Android O+,或 startService() plus startForeground()在 Android 7.1 及更早版本上)。