Android 奥利奥服务

Service on Android Oreo

在 Android Oreo 上,如果我的应用程序在前台启动服务然后关闭我的应用程序,该服务稍后会被终止吗?还是它会活着?

从这个视频来看 post 如果应用程序在后台运行,服务似乎会被终止,https://www.youtube.com/watch?v=Pumf_4yjTMc&t=198s

但是,在测试时,该服务非常活跃。将不胜感激任何富有成效的反馈。

如果您关闭或销毁您的应用程序,服务调用和所有当前应用程序进程将被终止,因为所有这些进程都链接到您的应用程序的生命周期,如果生命周期关闭, killed or crashed,所有的进程都走到了一起。

服务最终被终止

When an app goes into the background, it has a window of several minutes in which it is still allowed to create and use services. At the end of that window, the app is considered to be idle. At this time, the system stops the app's background services, just as if the app had called the services' Service.stopSelf() methods.

https://developer.android.com/about/versions/oreo/background.html

感谢您的回答!感谢您的回复。这是我的错,因为我切换了不针对 API 26 的工作分支。 我认为,值得一提的是,上述限制仅适用于应用程序针对 api 26 (Android O) 的情况。 我已经开始转向 Job scheduler,它似乎正在 Android O 上工作。