Android:如果未绑定服务在前台运行,系统会停止它吗?
该应用程序使用绑定服务。因此,该服务不会在任何地方使用 startService 启动。每个需要访问该服务的活动都使用bindService 绑定到该服务。
在某些情况下,服务会进入前台(使用 startForeground)。
特别是,可能存在这样一种情况:没有任何内容与服务绑定(根据文档,这意味着服务将被停止),但它在前台运行(这意味着它不会被停止)。这些规则中哪一个具有优先权?当未绑定的服务在前台运行时,系统会停止它吗?
谢谢。
The application uses bound service. So, the service is NOT started using startService anywhere. Every activity which needs to access the service binds to it using bindService.
In some situations service is going foreground (with startForeground).
In particular there might be a situation when nothing is bound to service (which, according to the doc means that service will be stopped) but it's running in the foreground (which means that it wont' be stopped). Which of those rules have priority? Will system stop unbound service when it's running in foreground?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这并不是特别有用,因为该进程已经位于前台,因为使用该服务的活动位于前台。
当最后一个客户端解除绑定后,该服务将被销毁。
startForeground()
不会影响这一点。This is not particularly useful, as the process will already be in the foreground, because the activity using the service is in the foreground.
The service will be destroyed after the last client has unbound from it.
startForeground()
does not impact this.