在 Android Oreo 中将绑定服务排除在后台执行限制之外的原因
Reason behind keeping bound services out of Background Execution Limits in Android Oreo
在 Android Oreo
为什么 bound services
仍然被允许而 (Started Services
& IntentServices
) 是不允许的。
假设我有一个绑定服务,我在 activity 的 oncreate()
方法中绑定并在 activity 的 ondestroy()
方法中解除绑定。现在,当用户来到此 activity 并按下 home button
时,我的 app goes in background
现在无限期地使用该绑定服务将使用我认为开发人员希望从中删除的资源Oreo
,所以你不觉得保留绑定服务的原因是什么,如果它们也会浪费内存资源。
In Android Oreo why bound services still allowed whereas (Started Services & IntentServices) are not allowed.
允许所有这些服务。但是,启动的非前台服务只能 运行 ~1 分钟。
now for the indefinite amount of time this bound service will use resources
Android 将在一段时间后终止您的后台进程,与之前没有什么不同。纯绑定服务不会提高流程的重要性;只有启动的服务才可以。
但是,绑定服务进程的重要性受服务自身进程和任何绑定客户端进程的支配。这就是为什么绑定服务不会直接受到 Android 8.0 更改的影响 — 服务的生命周期更多地由客户端而不是服务本身来管理。因此,在服务被核心 OS 进程(例如 NotificationListenerService
)绑定的情况下,系统有效地控制该服务需要存在多长时间。在你的情况下,由于客户端和服务在同一个应用程序和同一个进程中,你的进程可以在后台正常终止。
在 Android Oreo
为什么 bound services
仍然被允许而 (Started Services
& IntentServices
) 是不允许的。
假设我有一个绑定服务,我在 activity 的 oncreate()
方法中绑定并在 activity 的 ondestroy()
方法中解除绑定。现在,当用户来到此 activity 并按下 home button
时,我的 app goes in background
现在无限期地使用该绑定服务将使用我认为开发人员希望从中删除的资源Oreo
,所以你不觉得保留绑定服务的原因是什么,如果它们也会浪费内存资源。
In Android Oreo why bound services still allowed whereas (Started Services & IntentServices) are not allowed.
允许所有这些服务。但是,启动的非前台服务只能 运行 ~1 分钟。
now for the indefinite amount of time this bound service will use resources
Android 将在一段时间后终止您的后台进程,与之前没有什么不同。纯绑定服务不会提高流程的重要性;只有启动的服务才可以。
但是,绑定服务进程的重要性受服务自身进程和任何绑定客户端进程的支配。这就是为什么绑定服务不会直接受到 Android 8.0 更改的影响 — 服务的生命周期更多地由客户端而不是服务本身来管理。因此,在服务被核心 OS 进程(例如 NotificationListenerService
)绑定的情况下,系统有效地控制该服务需要存在多长时间。在你的情况下,由于客户端和服务在同一个应用程序和同一个进程中,你的进程可以在后台正常终止。