gpt4 book ai didi

android - Android O 上的 JobScheduler 行为

转载 作者:太空狗 更新时间:2023-10-29 15:50:33 25 4
gpt4 key购买 nike

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

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

最佳答案

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 分钟。

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

关于android - Android O 上的 JobScheduler 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44240178/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com